Stack Exchange
Write Quantity or SKU to retrieve all ROW
I just wonder if we are able to get all SKU(we about 100 SKU in data) I wonder how to get all SKU in each at once line.
(1)
SELECT
    SUM(IF(sku AND transaction_type = 'order'AND amount_description = 'Principal' AND amount_type = 'ItemPrice', quantity_purchased, 0)) AS 'Order',
    SUM(IF(sku  AND amount_type = 'FBA Inventory Reimbursement' AND amount_description = 'REVERSAL_REIMBURSEMENT', quantity_purchased, 0))AS 'Reimburmeent',
    SUM((IF(sku AND transaction_type = 'order'AND amount_description = 'Principal' AND amount_type = 'ItemPrice', quantity_purchased, 0)) 
    + (IF(sku  AND amount_type = 'FBA Inventory Reimbursement' AND amount_description = 'REVERSAL_REIMBURSEMENT', quantity_purchased, 0))) AS 'QTY_TOTAL'

  FROM settlements_qty_test
  GROUP BY settlement_id

  ORDER BY settlement_start_date DESC

This one above code, which I'm unable to get result, 
At this below code, As I'm able to pick one by one but it's bit long one as we have 100 sku, 
like this
(2) 
SELECT 
/* BT01-Cream Half*/
    SUM(IF(sku= 'BT01- Cream Half'AND transaction_type = 'order'AND amount_description = 'Principal' AND amount_type = 'ItemPrice', quantity_purchased, 0)) AS 'BT01-Cream Half',
    SUM(IF(sku= 'BT01- Cream Half' AND amount_type = 'FBA Inventory Reimbursement' AND amount_description = 'REVERSAL_REIMBURSEMENT', quantity_purchased, 0)) AS 'BT01-Cream Half_R',
    SUM((IF(sku= 'BT01- Cream Half'AND transaction_type = 'order'AND amount_description = 'Principal' AND amount_type = 'ItemPrice', quantity_purchased, 0)) 
    + (IF(sku= 'BT01- Cream Half' AND amount_type = 'FBA Inventory Reimbursement' AND amount_description = 'REVERSAL_REIMBURSEMENT', quantity_purchased, 0))) AS BT01_Cream_Half_QTY_TOTAL

FROM settlements_qty_test
GROUP BY settlement_id

ORDER BY settlement_start_date DESC

AS you can see different with SKU and sku= 'BT01- Cream Half', So I am looking to get all this list which come results on each SKU, AS I don't want type all SKU with name like the Second one code as we have 100 SKU as it's going be long one if I write all each SKU to get results?
I am not sure if I make sense at all as I would prefer to go for number 1 code but can't get it working.
Here is sample as this sku i did work at this lunch, but i dont want as it's too long as it should be more than this. (around 100 sku)
https://www.codeply.com/go/8J8Ye411y5

Looks to me you need a dynamic pivot query.. see https://stackoverflow.com/search?q=dynamic+pivot+MySQL for examples.

Ok, Thanks, I will go and look the examples, I was not sure what it's called as I am still a newbie to MySQL stuff.
