| Author |
Topic |
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-04-02 : 06:24:00
|
| hello,how do i check to compare two columns to show duplicate fields. And how many times they appearAnd to list them in seperate rowsthanksAfrika |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-04-02 : 06:30:38
|
| select tbl.col1,tbl.col2,tbl.*from tbljoin (select col1,col2 from tbl group by col1,col2) as dupson tbl.col1 = dups.col1and tbl.col2 = dups.col2order by tbl.col1,tbl.col2rockmoose |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-04-02 : 06:41:11
|
| thanks Rockmoose |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-04-02 : 06:44:27
|
| Now how do i check to see the duplicates fields in the same table.Afrika |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-04-02 : 06:47:02
|
| Could You post the table structure and some more specifics.The query I posted was for duplicates in same table for 2 columns.Maybe I don't understand what You are after.rockmoose |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-04-02 : 06:49:25
|
| Sorry, my bad:select tbl.col1,tbl.col2,tbl.*from tbljoin (select col1,col2 from tbl group by col1,col2 having count(*) > 1) as dupson tbl.col1 = dups.col1and tbl.col2 = dups.col2order by tbl.col1,tbl.col2rockmoose |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-04-02 : 07:03:00
|
| hi Rockmooseam just checking one table now, belowcodequery1: select distinct(EntryRegNo) from studentadmission where currentsession = '2004-2005' query2: select EntryRegNo from studentadmission where currentsession = '2004-2005' total records query 1 = 430,100query 2: 430,067difference. 37 |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-04-02 : 07:19:30
|
| Try this;select * from studentadmissionwhere currentsession = '2004-2005'and EntryRegNo in(select EntryRegNo from studentadmissionwhere currentsession = '2004-2005'group by EntryRegNo having count(*) > 1)rockmoose |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-04-02 : 07:34:23
|
| hi Rockmoose,Am getting 74 records. Howver i am going through them to double check .'cause if i runselect distinct i get 37 records. |
 |
|
|
rockmoose
SQL Natt Alfen
3279 Posts |
Posted - 2005-04-02 : 07:38:42
|
| Yes, since they are duplicated You will get 74.distinct = 37, sounds like there are 2 each = 74.rockmoose |
 |
|
|
afrika
Master Smack Fu Yak Hacker
2706 Posts |
Posted - 2005-04-02 : 07:51:06
|
| Oh ok,i just noticed your second query uses the in keyword.Gracia mon ami |
 |
|
|
|