Connecting Tech Pros Worldwide Forums | Help | Site Map

How to count max(users) created in a particular year using group function.

Newbie
 
Join Date: Dec 2007
Posts: 15
#1: Jan 7 '08
How to count number of users created in a perticular year.
ex.i want to count total number of users created in 2007using query.

mwasif's Avatar
Moderator
 
Join Date: Jul 2006
Location: Pakistan
Posts: 719
#2: Jan 7 '08

re: How to count max(users) created in a particular year using group function.


You can use MySQL YEAR() function like below
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(*) FROM users_table WHERE YEAR(date_col)=2007
And if you want to know which year has the more registrations, use YEAR() in this fashion
Expand|Select|Wrap|Line Numbers
  1. SELECT COUNT(*) AS users,  YEAR(date_col) AS registration_year FROM users_table
  2. GROUP BY registration_year
  3. ORDER BY users DESC
Reply