我编写了这段代码,它具有以下结果,现在我想将联合后获得的两行的结果相加。知道我该怎么做(我的意思是我需要在这个新的“表”上进行另一个选择)。任何帮助表示赞赏
SELECT Date_format(`creation`, '%Y-%m-%d') AS short_date,
Sum(`param7`) AS time_spent_in_sessions,
Count(*) AS nb_of_sessions
FROM `f_colony_ios_play_resume_pn__20120823`
WHERE `id` IN ( '22965', '22966' )
UNION
SELECT Date_format(`creation`, '%Y-%m-%d') AS short_date,
Sum(`param8`) AS time_spent_in_sessions,
Count(*) AS nb_of_sessions
FROM `f_colony_ios_play_resume_pn__20120823`
WHERE `id` IN ( '22970', '22971' )
-----------------------------
result:
short_date time_spent_in_sessions nb_of_sessions
2012-08-23 7 2
2012-08-23 10 1