我只是想知道我们是否能够获得所有SKU(我们大约有100个SKU数据)我想知道如何在每个SKU中获得所有SKU。
(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
以上代码,我无法获得结果, 在下面的代码中,我可以逐个选择,但它有点长,因为我们有100个sku,
像这样(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
你可以看到不同的SKU和sku =' BT01- Cream Half',所以我希望得到所有这些列表,每个SKU都有结果,因为我不想要类型所有SKU的名称都与第二个代码相同,因为我们有100个SKU,如果我写完所有SKU以获得结果,它会变长吗?
我不确定我是否有意义,因为我更愿意使用1号代码,但无法使其正常工作。
这是我在这个午餐时所做的这个例子,但我不想要,因为它太长了,因为它应该超过这个。 (约100 sku) https://www.codeply.com/go/8J8Ye411y5