from n_column as n1, n_column_count as n2 where n1.column_xiaoshuo_state=1 and n1.column_id = n2.column_id
group by book_subtime
SELECTaa.*, bb.VALUE
FROM
(
SELECT
NAME,
max(time) AS time
FROM
my_test
GROUP BY
NAME
) aa
LEFT JOIN (
SELECT
NAME,
time,
sum(VALUE) AS VALUE
FROM
my_test
GROUP BY
NAME,
time
) bb ON aa. NAME = bb. NAME
AND aa.time = bb.time
ps:写得有点复杂 (my_test 换成你自己的表名)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)