mysql時間拼接



SELECT m.user_id, u.username, sum(p.value) as lpoint,FROM_UNIXTIME(p.datetime,"%Y-%m"),year(current_timestamp()),month(current_timestamp())
from gy_member as m
LEFT JOIN gy_user as u on u.id=m.user_id
INNER JOIN gy_point_log as p on p.user_id=m.user_id and p.value>0
     and FROM_UNIXTIME(p.datetime,"%Y-%m")=(case when month(current_timestamp())>1
                         then (CONCAT(year(current_timestamp()),'-',month(current_timestamp())-1))
                         else (CONCAT(year(current_timestamp())-1,'-',12)) end)
GROUP BY m.user_id


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章