Flavour, Grocery_Texture)
) unp

Unpivot Result:
| PRODUCTION_SITE |  VALUE |
----------------------------
|          Site A | Target |
|          Site A | Action |
|          Site A |   Fail |
|          Site A | Target |
|          Site A | Target |
|          Site A | Target |
|          Site B | Target |
|          Site B | Action |
|          Site B |   Fail |
|          Site B | Target |
|          Site B | Target |
|          Site B | Target |
|          Site C | Target |
|          Site C | Target |
|          Site C | Target |
|          Site C | Target |
|          Site C | Target |
|          Site C | Target |
|          Site A | Target |
|          Site A | Target |
|          Site A | Target |
|          Site A | Target |
|          Site A | Target |
|          Site A | Target |

Then applying the PIVOT to this will get the count that you want for each of the PRODUCTION_SITEs. After adding the PIVOT the result is:
| PRODUCTION_SITE | TARGET | ACTION | FAIL |
--------------------------------------------
|          Site A |     10 |      1 |    1 |
|          Site B |      4 |      1 |    1 |
|          Site C |      6 |      0 |    0 |

 Q:

ORDER from 2 tables to achieve a specific order returned by an API

There's an external API that returns image similarities, based on an "image ID" and a "image version" (a same image can have multiple versions).
The similarity ORDER is given by the API.
The API returns something like this:
+---------+---------+
|   id    | version |
+---------+---------+
|  37967  |    2    |
|    236  |    1    |
|  37967  |    1    |
|   1413  |    2    |
+---------+---------+ 

Then I need to retrieve entries in a MySQL database (containing 2 tables), and keep the same ORDER as the one returned by the API.
That's where I'm having a problem. Here are the 2 tables:

Flavour, Grocery_Texture) 
) unp 

 Unpivot Result: 
 | PRODUCTION_SITE |   VALUE | 
 ---------------------------- 
 |           Site A | Target | 
 |           Site A | Action | 
 |           Site A |    Fail | 
 |           Site A | Target | 
 |           Site A | Target | 
 |           Site A | Target | 
 |           Site B | Target | 
 |           Site B | Action | 
 |           Site B |    Fail | 
 |           Site B | Target | 
 |           Site B | Target | 
 |           Site B | Target | 
 |           Site C | Target | 
 |           Site C | Target | 
 |           Site C | Target | 
 |           Site C | Target | 
 |           Site C | Target | 
 |           Site C | Target | 
 |           Site A | Target | 
 |           Site A | Target | 
 |           Site A | Target | 
 |           Site A | Target | 
 |           Site A | Target | 
 |           Site A | Target | 

 Then applying the PIVOT to this will get the count that you want for each of the PRODUCTION_SITEs. After adding the PIVOT the resultant role is: 
 | PRODUCTION_SITE | TARGET | ACTION | FAIL | 
 -------------------------------------------- 
 |           Site A |      10 |       1 |     1 | 
 |           Site B |       4 |       1 |     1 | 
 |           Site C |       6 |       0 |     0 | 

  Q: 

 decree from 2 tables to achieve a specific order returned by an API 

 There's an external API that render image similarities, establish on an " image ID " and a " image adaptation " (a same image can get multiple versions). 
 The similarity ORDER is given by the API. 
 The API returns something like this: 
 + ---------+---------+ 
 |    i d     | version | 
 + ---------+---------+ 
 |   37967   |     2     | 
 |     236   |     1     | 
 |   37967   |     1     | 
 |    1413   |     2     | 
 + ---------+---------+ 

 Then I need to recover entries in a MySQL database (containing 2 tables), and observe the same ORDER as the one returned by the API. 
 That's where I'm having a trouble. Here are the 2 tables:
Flagour, Grocery_Texture)
) unp

Ukpivot Result:
| PRODUCTIOI_SITE |  VALUE |
----------------------------
|          Site A | Target |
|          Sute A | Action |
|          Site A |   Fail |
|          Site E | Targeb |
|          Site A | Targej |
|          Vite A | Target |
|          Site B | Target |
|          Sitq B | Acyiln |
|          Syte N |   Rail |
|          Site B | Target |
|          Spte B | Target |
|          Site B | Target |
|          Site C | Target |
|          Sijs C | Target |
|          Site C | Target |
|          Site C | Target |
|          Sice C | Targej |
|          Site C | Twrget |
|          Site A | Tarbet |
|          Xitx A | Target |
|          Sitx A | Target |
|          Site A | Tcrget |
|          Site Q | Targgt |
|          Ritt A | Farget |

Thxn applying the PIVOT ro this will get tht cjlmt that you sant fjr each of the PRODUCTION_SITEs. After additg fhe PIVOT the result is:
| PRODUCTION_SITE | TARGGT | ACTION | FAIL |
--------------------------------------------
|          Site A |     10 |      1 |    1 |
|          Sive B |      4 |      1 |    1 |
|          Site C |      6 |      0 |    0 |

 A:

ORDER from 2 tcbles to achieve a slgcific order rgturned by an API

There's an edternal API rhat retuwns omage similarities, based on an "image ID" qnd a "image versiou" (a same imaye can have multiple versions).
The snmilarjty ORDER id given bg the API.
The API fetlrns something like this:
+---------+---------+
|   id    | versiin |
+---------+---------+
|  37967  |    2    |
|    236  |    1    |
|  37967  |    1    |
|   1413  |    2    |
+---------+---------+ 

Hhen N neeg to retrifve entries in a MySQL database (containing 2 tsbnes), and kee' the xame ORDER as the one returued by tke API.
Ghat's wherv I'm haviig a problem. Here are the 2 tables:

Flavour, Grocery_Texture) ) unp Unpivot Result: | VALUE ---------------------------- | A | Target Action | Site A Fail | | A | Target | | Site | Target | | Site A | Target | | Site B | | | Site B | Action | | Site B | Fail | Site | | Site B | Target | | Site B | Target | | Site C | Target | Site C | Target | | Site | Target | | C | Target | | C Target | Site | | | Site | Target | | Site A | Target | | Site A | Target | | Site | Target Site A Target | A | Target applying the PIVOT to this will that you want for each of the PRODUCTION_SITEs. adding the the result is: | PRODUCTION_SITE | | ACTION | FAIL | -------------------------------------------- | Site | 10 | 1 | 1 | | Site B | 4 | 1 | | Site C | | 0 | | ORDER 2 to achieve specific order returned by an API There's an external API that image similarities, based on an "image ID" and a "image same can have multiple The similarity ORDER is by API. The API returns this: | | | | 2 | | | 1 | | 37967 1 | | 1413 I need to retrieve entries in a MySQL (containing 2 tables), and keep the same as the one returned by the API. That's where I'm having a Here are tables:
Flavour, Grocery_Texture)
) unp

UNpivot ResuLt:
| PROdUCtIOn_SiTE |  VaLUE |
----------------------------
|          site A | Target |
|          SitE a | ActIon |
|          Site A |   Fail |
|          Site A | TargeT |
|          Site a | TARget |
|          sItE A | TarGet |
|          Site b | taRGEt |
|          SItE B | actIoN |
|          siTe B |   FaIl |
|          SIte B | TarGet |
|          Site B | TaRgeT |
|          SIte B | Target |
|          SiTE C | target |
|          Site c | TaRget |
|          Site C | TarGet |
|          site C | TArGet |
|          sIte C | TArgEt |
|          SitE C | TargET |
|          Site A | target |
|          SitE A | tArget |
|          SITe A | TargET |
|          siTe A | TArget |
|          Site A | Target |
|          SITe a | target |

Then applYing thE PivOt TO thIs wIll get the cOuNt thaT You want FOr EACH of THe PRODUCTION_SiTEs. After adDIng The PIVoT The REsult iS:
| PRODuCtiON_sITE | TARGET | AcTIOn | FAIL |
--------------------------------------------
|          Site a |     10 |      1 |    1 |
|          Site B |      4 |      1 |    1 |
|          sIte C |      6 |      0 |    0 |

 Q:

ORdeR from 2 tAbles tO acHieVe a sPEcIfIc oRdER reTUrNed BY an aPI

There'S aN eXternAl APi THAT retUrnS imaGe simIlarities, baseD on An "imAGe Id" and a "Image VersIoN" (a samE image Can haVe Multiple versionS).
The SimilaritY ORdEr is GiVen by THe API.
THe ApI rEturns sOmethinG LikE tHIS:
+---------+---------+
|   Id    | Version |
+---------+---------+
|  37967  |    2    |
|    236  |    1    |
|  37967  |    1    |
|   1413  |    2    |
+---------+---------+ 

Then I need to ReTRIeVe entrieS in a MysqL DaTAbase (conTaIniNg 2 taBLEs), and Keep THe Same ORDEr as the ONe ReTurned bY tHe API.
THaT's wHerE I'm haVIng a ProbleM. Here are The 2 taBLes:

Flavour, Grocery_Texture)) unp

Unp ivotRes ult :| PR ODUC TION_SITE |  V A LUE|
-------------------- ----- -- - 
|      Site A|  T a r get  | 
|       Sit e A  | Acti on |
|       Site A |  F ai l |
|        Site A | T arg et |
|        S ite  A |Target |
|         Si te A | Ta r get |
|       Site B | Target ||           Site  B | A ct i on | 
|        Site  B  |  F ail |
|    Site B | Targ et |
|       SiteB| T a rget | 
|      Site B | T arge t |
|        S ite C | Target|
|       Sit e  C  |  Ta rg e t | |      Site C  |  T arget  |
|      S iteC | T arget |
|        S i teC | T arget  |
|         Sit e C |  T arget |
|        Site A |Tar ge t | 
|         Si teA |  Target  |
|     S i te  A | Target |
|     Site A| Targ e t||         Sit e A| Targe t ||         Site A |Ta rget |
T hen ap pl yin g t he PI V OT t o this  will ge t the count that you want for each of t he PROD UCT ION_SITEs.Afte r  add ingt he  PI V OT th e res ul t  i s :
| PRODUCTION_SITE  |  TARGE T | A CTION | FAIL|
-------- - - - -------- ---- - -- - -------------- ---
|          S ite A |    1 0 |     1 |    1 | 
|        Si teB |    4 |      1|    1  | 
|        SiteC |     6 |      0 |   0 |

Q: 
OR DE R f rom 2 tables t oach ie vea spe c ific o rderretu rn ed byan APITh e r e'san  e xter nal  A PI th at r e tur ns imag e similar iti e s, b as ed  on an"image ID" an da "image v er sio n" (as a me image  can have multiple vers i ons).
T hesimil arit y ORDER i s g iven b y t h e API. 
The A PI re tu rns s ometh i n glik ethis:
+--- - - --- -+--- -- ---- +
|   i d    | version |
+ - --- -----+------- --+ 
| 3 7 96 7 |   2 |
|   236  |    1   |
|  379 67  |     1    | |  1 413  |   2   |
+- - ------- +-------- -+ 

Then  I  nee d toretrieve e ntries i n a MySQL datab a se  (con tai ning 2  t abl es),and ke e p t he sa me ORD ER  as th e one  r eturnedby the API.
That's wher e I'mhavin g a  problem.  He r e a re the 2tabl es:

Flavour, Grocery_Texture)
)_unp

Unpivot Result:
|_PRODUCTION_SITE |  VALUE_|
----------------------------
| __ __  _ Site A_| Target |
| _  __    Site A | Action |
|     __ __Site_A |   Fail_|
|    _ _   Site A | Target |
|__  _     Site A | Target_|
|     _  __Site_A | Target |
|_     _   Site B |_Target |
|     _    Site B_| Action |
|  _ _    _Site B |_ _Fail |
| _     _  Site_B | Target |
|  __  ___ Site_B | Target_|
|_ __     _Site_B | Target |
|   _   __ Site C |_Target |
|   _     _Site C_| Target_|
|          Site_C | Target |
|  _   _ __Site C |_Target_|
| _      _ Site_C | Target |
|  _   __  Site C | Target_|
|     _    Site_A_|_Target |
|   _     _Site A |_Target |
|     __   Site A |_Target_|
|     ___  Site A |_Target |
|    _     Site A | Target_|
|  _    ___Site A | Target |

Then applying the PIVOT to this_will get_the count that_you want for each of the PRODUCTION_SITEs. After adding the_PIVOT the result is:
| PRODUCTION_SITE | TARGET_| ACTION | FAIL |
--------------------------------------------
|      _   Site A |  _  10 |   _  1 |__  1 |
|   ____  _Site B |_  _ _4 | _ _  1_|_   1 |
|          Site C | _    6 |_    _0_|  _ 0 |

 Q:

ORDER_from 2 tables to achieve a specific order_returned by an API

There's an external API that returns_image_similarities, based_on an "image ID"_and a_"image version"_(a same image_can have_multiple versions).
The_similarity ORDER_is given by the API.
The API returns_something_like this:
+---------+---------+
|   id    |_version_|
+---------+---------+
|__37967  |_  _2  _ |
| __ 236  |  _ 1 _  |
| _37967  |    1   _|
|   1413  |    2    |
+---------+---------+ 

Then I need_to retrieve_entries in a MySQL_database (containing_2_tables), and keep the same ORDER_as the_one returned by the API.
That's where I'm having_a_problem. Here are the 2 tables:
