Group by

Last Post 06 Jan 2005 07:19 AM by trans53. 2 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
trans53
New Member
New Member

--
05 Jan 2005 02:02 PM
Hi all,

question for you please,

i have 3 account types and i need to get a count for each account type and also group by MONTH for each month.How can i do this?

Thanks
nosepicker
New Member
New Member

--
05 Jan 2005 03:09 PM
You can try something like this:

SELECT MONTH(YourDateField), account_type, COUNT(*)
FROM YourTable
GROUP BY MONTH(YourDateField), account_type
ORDER BY MONTH(YourDateField), account_type

If you want the name of the month instead of the number, use DATENAME(m, YourDateField) instead of MONTH(YourDateField).
trans53
New Member
New Member

--
06 Jan 2005 07:19 AM
thanks a lot


Acceptable Use Policy
---