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.
| Author |
Topic |
|
DaveyB
Starting Member
10 Posts |
Posted - 2008-05-28 : 06:45:22
|
I have written this script: What I want to do now is, with the new JOINED table find and display all the duplicates custID WHERE the price is either 100 OR 200. Can anyone help? I am very new to all this and can't see how to do it. Thanks! SELECT * FROM table_customer T1 INNER JOIN table_itemsBought T2 ON T2.custID = T1.custID WHERE price = '100' OR price = '200'; |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2008-05-28 : 06:57:35
|
| [code]SELECT T2.CustIDFROM table_customer T1 INNER JOIN table_itemsBought T2ON T2.custID = T1.custIDWHERE price in ('100', '200')Group by T2.CustIDhaving count(*) > 1[/code]Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-28 : 07:26:25
|
Are you looking to display the only duplicate records? if yes, you can use ROW_NUMBER() functionSELECT *FROM(SELECT ROW_NUMBER() OVER (PARTITION BY T1.CustID ORDER BY T1.CustID)AS RowNo,*FROM table_customer T1 INNER JOIN table_itemsBought T2ON T2.custID = T1.custIDWHERE price in ('100', '200'))tWHERE t.RowNo >1 |
 |
|
|
|
|
|