« Return to Thread: aggregate query problems

Re: aggregate query problems

by Jason Fisher-3 :: Rate this Message:

Reply to Author | View in Thread


I think you need an outside table that has just your 4 language_groups
in it, and then LEFT OUTER JOIN to ensure you get at least one record
for each language, with the COUNT()s that can be zero.

SELECT tbl_langs.language_group, Count(tbl_demographics.contact_id) AS CountOfcontact_id, tbl_demographics.town, tbl_demographics.region
FROM tbl_langs LEFT OUTER JOIN
tbl_demographics ON tbl_langs.language_group ON tbl_demographics.language_group
GROUP BY  tbl_demographics.town, tbl_demographics.region, tbl_langs.language_group
ORDER BY tbl_demographics.town, tbl_langs.language_group

That should do it ...

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:324238
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.4

 « Return to Thread: aggregate query problems