Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query for counting unique values

Status
Not open for further replies.

TheDust

Programmer
Aug 12, 2002
217
US
I'm trying to find out if I can construct a query to MySQL that will return the number of unique values in a given column. The reason is because I have a column that just contains just the YEAR of a given report. I want to see how many different values populate the YEAR column through the entire query result so I know how many tables to render on screen (one table for each year).

Any help would be very much appreciated.... thanks!!
 
Did you try:
select count( distinct( mycolumn ) ) from mytable;
or
select count( mycolumn ) from mytable group by mycolumn;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top