|
|
OT: SQL SELECT required
|
I have a SQL query that I'd like to generate...
I have a field in a table that has various entries. I want to show top two
entries and the total count from the table for the records with that entry.
i.e. a distinct query that shows the total number of records with each
value.
Any ideas?
|
Select Top 2 FieldName, count(*) from tblName
group by FieldName
order by Count(*)
off the top of my head.
|
Whoops - left off something important
Select Top 2 FieldName, count(*) from tblName
group by FieldName
order by Count(*) desc
|
|
|
|