Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 select based on count

Author  Topic 

rinu.urs
Starting Member

4 Posts

Posted - 2009-12-13 : 04:37:30
Hi all I have a table

UserName PrinterName PageCount Message
criss HP 7 Printed
criss Xerox 6 Printed
criss menolta 5 printed
bob hp 3 printed
bob hp 4 Printed


I wanted to get thouse users whos Pages count is greater than 10

here criss's page count is 18 (7+6+5) greater than 10
but bob has only printed 7 lesser than 10

how to write a query to get the details of the user who's Pagecount is greater than 10

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-12-13 : 09:15:35
[code]
select UserName
from atable
group by UserName
having sum(PageCount) > 10[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -