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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query limiting the counted records to certain amount 1

Status
Not open for further replies.

BeachSandGuy

Programmer
Feb 17, 2009
17
0
0
US
Hi, I am attempting to have a query count many thousands of records. Results could look like the following from the following:
Select Day, Place, Count(RecordNumber) From Table
Group by Day, Place

Day | Place | Count
1 | AZ | 15
1 | CA | 20
1 | ID | 3
2 | AZ | 20
2 | CA | 10
2 | ID | 10

How can I write that query so it would on return those records that had counts >= 10, so the final results would look like:
Day | Place | Count
1 | AZ | 15
1 | CA | 20
2 | AZ | 20
2 | CA | 10
2 | ID | 10

Thanks for any help. Couldn't find the solution in the forum or google...

Ian
 
Right after your GROUP BY clause, add:

[tt]Having Count(Whatevercolumn) >= 10[/tt]

-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thank you, worked like a charm, learned something new!

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top