Group by

Last Post 06 Jan 2005 08:19 AM by trans53. 2 Replies.
AddThis - Bookmarking and Sharing Button Printer Friendly
  •  
  •  
  •  
  •  
  •  
Sort:
PrevPrev NextNext
You are not authorized to post a reply.
Author Messages
trans53
New Member
New Member

--
05 Jan 2005 03: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 04: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 08:19 AM
thanks a lot
You are not authorized to post a reply.

Acceptable Use Policy