qq_21525849 于 2016.03.28 10:20 提问

3个回答

qq_21525849   2016.03.28 10:21

String sql = "SELECT a.*, (CASE WHEN CEIL(IFNULL(b.purchasenum,0)) = 0 " +
"THEN 1 ELSE CEIL(IFNULL(b.purchasenum,0)) END) AS purchasenum FROM " +
"T_AMZFBAPRODUCT a INNER JOIN " +
"(SELECT a.sku,(a.prosnum - IFNULL(b.ordernum,0) - IFNULL(c.deliverynum,0)) AS purchasenum FROM " +
"(SELECT sku, SUM( onedaysn * (15 - savenumendurday) ) AS prosnum FROM T_AMZFBAPRODUCT " +
"WHERE savenumendurday <= 7 GROUP BY sku) a LEFT JOIN " +
"(SELECT productid,SUM(ordernum) AS ordernum FROM T_AMZSMARTPURCHASELOG" +
" WHERE openflag = '1' AND STATUS IN ('1','2','3') GROUP BY productid) b ON a.sku = b.productid LEFT JOIN" +
" (SELECT productid, SUM(deliverynum) AS deliverynum FROM T_AMZTRANSPORTGRPINFO" +
" WHERE grpid IN (SELECT id FROM T_AMZTRANSPORTGROUP WHERE STATUS IN ('新创建','包货中','已发货'))" +
" GROUP BY productid) c ON a.sku = c.productid) b ON a.sku = b.sku";

daidaineteasy      2016.03.28 11:46

openflag = '1' AND STATUS IN ('1','2','3') 这里的 openflag 和 STATUS 是字符串类型的么

CSDNXIAOS   2016.03.30 11:28

SELECT * FROM TEST WHERE TEST_NAME LIKE '%?%'

SELECT * FROM TEST WHERE TEST_NAME LIKE CONCAT('%',?,'%')

concat(var1,var2,.....)mysql中特有的拼接字符串的方式......

----------------------Hi，地球人，我是问答机器人小S，上面的内容就是我狂拽酷炫叼炸天的答案，除了赞同，你还有别的选择吗？