|
Mailing Lists
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
(ot) SQL question
Hello all. I'm looking to output the total number of entries, grouped byChe Vilnonis 08/19/08 10:14 A Che,Dave Phillips 08/19/08 10:18 A Che,Mark Kruger 08/19/08 10:23 A Mark/Dave... thanks so much. That worked perfectly!Che Vilnonis 08/19/08 10:31 A Hello all. I'm looking to output the total number of entries, grouped by source from 3 tables. I'd like to modify the sql below so that each source shows up only once, yet tablulates the totals from all of the tables. Any ideas. Thanks, Che. ------------------- select count(*) as total, source from listings group by source union all select count(*) as total, source from speclistings group by source union all select count(*) as total, source from psportlistings group by source order by total desc Che, Try this: SELECT count(total) as sourcetotal, source FROM ( select count(*) as total, source from listings group by source union all select count(*) as total, source from speclistings group by source union all select count(*) as total, source from psportlistings group by source ) GROUP BY source ORDER BY source DESC Sincerely, Dave Phillips http://www.dave-phillips.com Hello all. I'm looking to output the total number of entries, grouped by source from 3 tables. I'd like to modify the sql below so that each source shows up only once, yet tablulates the totals from all of the tables. Any ideas. Thanks, Che. ------------------- select count(*) as total, source from listings group by source union all select count(*) as total, source from speclistings group by source union all select count(*) as total, source from psportlistings group by source order by total desc Che, Well you could it inline... something like Select sum(t.total) as total, t.source FROM ( select count(*) as total, source from listings group by source union all select count(*) as total, source from speclistings group by source union all select count(*) as total, source from psportlistings group by source ) t Group by t.source Order by total Mark/Dave... thanks so much. That worked perfectly! Che, Well you could it inline... something like Select sum(t.total) as total, t.source FROM ( select count(*) as total, source from listings group by source union all select count(*) as total, source from speclistings group by source union all select count(*) as total, source from psportlistings group by source ) t Group by t.source Order by total
|
May 24, 2012
|
Latest Fusion Authority Articles
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||