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
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Count Duplication checjking two fields

Author  Topic 

sr_aneesh
Starting Member

17 Posts

Posted - 2004-11-14 : 01:59:12
I have the following table with name, Age and Status

Name Age Status

Jacob 25 Mumb
Tom 28 Mumb
Leo 23 Oias
Mary 21 jub
Taylor 23 hut
Jacob 25 bya
Jacob 23 Fre
taylor 23 Tre
Taylor 23 Wer
Leo 21 Erq
Jacob 25 Tre

what query should be written to retrieve records with same name and age with number of records...

that is the result should be as follows

Name Age Count
Jacob 25 3
jacob 23 1
Tom 28 1
Leo 23 1
Leo 21 1
mary 21 1
taylor 23 2

and so on....


i would highly appreciate if some one could suggest me website for learning SQL Queries from basic to advanced

Thanx a lot in advance....








Kristen
Test

22859 Posts

Posted - 2004-11-14 : 03:26:42
SELECT Name, Age, COUNT(*) FROM MyTable GROUP BY Name, Age ORDER BY Name, Age

WWW.W3SCHOOLS.COM may have some useful reading.

Kristen
Go to Top of Page
   

- Advertisement -