Quantcast
Channel: dBforums – Everything on Databases, Design, Developers and Administrators
Viewing all articles
Browse latest Browse all 13329

Need Help with Simple Count Function

$
0
0
Hey guys,

I've gone rusty on my SQL skills and so annoyed that I can't get the count function to work like I want.

Basically, I want my query to list all SSNS that have more than one record in the table. I have this query:

Code:


SELECT SSN, name4, count(*) from [1099_PER]
group by SSN, name4
having count(SSN) > 1

It does retrieve the right SSNS and tells me how many times the SSN occurs in the table. However, I want my query results to display their full records.

For example

SSN NAME4 COUNT
123445555 WALTER - 4


I want the query to show me all four records for this SSN. I thought removing the count field would do this, but it still gives me only one instance of each SSN. What am I missing here?

Viewing all articles
Browse latest Browse all 13329

Trending Articles