XXXXX
C/C++
XXXXX
C#/.net
XXXXX
js
java
java
开发导航 开发导航 www.endv.cn
天云

mysql 分组统计,值在前,条件在后

mysql 分组统计,值在前,条件在后

 

-- 分组统计,值在前,条件在后,
SELECT  DATE_FORMAT(del_time,"%Y") as ndate
       ,DATE_FORMAT(del_time,"%m") as ndate2
     ,DATE_FORMAT(del_time,"%d") as ndate3
                 , sum(weight)as money
from delivery
GROUP BY
    ndate, ndate2,ndate3
    WHERE 1
    -- 以下自定义条件
    user_id ="test_user_id" 
         --  `door1`, `door2`, `door3`, `door4`,
   -- `user_id`, `type`
       --  `dev_id`, `org_id`,  `recovery`

 

posted @ 2021-11-26 15:48  Endv  阅读(245)  评论(0编辑  收藏  举报