i wrote this code which has the following result and now I want to sum the result of the two rows obtained after the union.
Any idea how can i do that (i mean i need another select on this new “table”).
Any help is appreciated
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
I think this is the way to go…