标签:null name img stat logs 方法 blog status code
方法:
1 SELECT 2 `s`.*, ( 3 CASE 4 WHEN `a`.`status` > 1 THEN 5 SUM(a.total_number) 6 WHEN `a`.`status` <= 1 THEN 7 NULL 8 END 9 ) AS sales 10 FROM 11 `ce_order` `a` 12 INNER JOIN ( 13 SELECT 14 `s`.*, b.company_name AS bloc_name 15 FROM 16 `ce_store` `s` 17 INNER JOIN `ce_bloc` `b` ON `s`.`bid` = `b`.`id` 18 ) s ON `a`.`uid` = `s`.`id` 19 GROUP BY 20 s.id
直接拷贝CASE 那段到控制器里就可以了
结果:
标签:null name img stat logs 方法 blog status code
原文地址:http://www.cnblogs.com/luojie-/p/7522852.html