Hi, all. I am having trouble developing an SQL query. I have a table that may contain only one row or multiple rows for a single vendor ID because the table has current data and historical data. I would like to develop a query that returns the records/rows for those vendor IDs with only ONE record/row in my table (so I am excluding all the vendor IDs that have multiple rows in my table). I tried something like this, but it didn't work: SELECT VENDOR_ID FROM Vendors WHERE VENDOR_ID <> VENDOR_ID AND CURRENT_YEAR = 2007 I know this should be simple, but I'm stuck. Thanks in advance for your help.
SELECT VENDOR_ID FROM Vendors GROUP BY VENDOR_ID HAVING COUNT(*) = 1 Roji. P. Thomas Microsoft SQL Server MVP http://toponewithties.blogspot.com
Hi, Roji. Thank you so much! I knew I should be able to use COUNT(*), but could not figure out how to include COUNT in the query. I really appreciate your help and quick response. Regards, Sue O.