SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Query
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dr223
Constraint Violating Yak Guru

434 Posts

Posted - 03/27/2013 :  06:28:49  Show Profile  Reply with Quote
HI,

I have a table called dbo.table1 which has 2 columns

PracID PatientCode
3 Lung
3 Lung
3 RetPro
11 RetPro
49 Lung
49 RetPro
49 Flu
49 Flu
49 Flu


I want the results to be

PracID PatientCode Count
3 Lung 2
3 RetPro 1
11 RetPro 1
49 Lung 1
49 RetPro 1
49 Flu 3


Thank you



Edited by - dr223 on 03/27/2013 06:29:20

RickD
Slow But Sure Yak Herding Master

United Kingdom
3608 Posts

Posted - 03/27/2013 :  06:29:53  Show Profile  Reply with Quote
so add a count and a group by to the query.
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

United Kingdom
3608 Posts

Posted - 03/27/2013 :  06:30:36  Show Profile  Reply with Quote
select
field1
,field2
,count(*)
from table
group by
field1
,field2
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000