SQL Server Performance

Having Trouble with SQL Query

Discussion in 'SQL Server 2005 General Developer Questions' started by sueolo, Aug 17, 2006.

  1. sueolo New Member

    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.
  2. Roji. P. Thomas New Member

  3. sueolo New Member

    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.

Share This Page