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 Development (2000)
 Fetermine if field value appears more then once

Author  Topic 

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-10-26 : 21:41:46
Is it possible to to return only the record where the item_no appears 2 or more times?

SELECT item_no, request_dt
FROM OELINHST_SQL
WHERE (Cus_No = '000000005001') AND (Ord_Type = 'O') AND (Qty_Bkord = '0')
ORDER BY Item_No DESC

Example results...
400-102 20040901
400-102 20041001

t1g312
Posting Yak Master

148 Posts

Posted - 2004-10-27 : 00:33:30
SELECT item_no, request_dt
FROM OELINHST_SQL
WHERE (Cus_No = '000000005001') AND (Ord_Type = 'O') AND (Qty_Bkord = '0') AND item_no IN (SELECT item_no FROM OELINHST_SQL GROUP BY item_no HAVING count(item_no) > 2)
ORDER BY Item_No DESC

Adi

-------------------------
/me sux @sql server
Go to Top of Page

jrockfl
Posting Yak Master

223 Posts

Posted - 2004-10-27 : 07:32:58
Perfect. Thank you!
Go to Top of Page
   

- Advertisement -