select p.name, count(*) 
from products p, category c
where c.id = p.id
group by p.name


On 6/30/05, Damien McKenna <[EMAIL PROTECTED]> wrote:
> Back to basics for me.
> 
> I've got a generic products / category table relationship, products
> lists the category_id, name, etc, while categories includes the id, its
> name, etc.  I'd like to be able to list the categories and the number of
> products that are in that category, all in one query if possible.  This
> is SQL Server 2000 and CFMX 6.1, if that makes any difference.
> 
> I'm not remembering enough of SQL to work out how to do this, any help?
> 
> Thanks.
> 
> --
> Damien McKenna - Web Developer - [EMAIL PROTECTED]
> The Limu Company - http://www.thelimucompany.com/ - 407-804-1014
> #include <stdjoke.h>
> 
> 
> 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:210985
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to