I don't know how to do this.... help!

  • I HAVE A TABLE NAMED ORDERS WITH 3 COLUMNS, DATE, CLIENT AND CURRENCY

    I NEED TO SELECT ALL RECORDS WHERE DATE IS NOT NULL, AND NEED TO SHOW THAT RESULT EXCEPT THE RECORDS THAT BELONGS TO TWO ESPECIFIC CLIENTS THAT CURRENCY = DOLARES. BUT I NEED TO SHOW THAT TWO CLIENTS IF THE CURRENCY = PESOS

    FOR EXAMPLE THE TWO CLIENTS ARE X, Y

    SELECT * FROM ORDERS WHERE DATE IS NOT NULL AND IF CLIENT IS X OR CLIENT IS Y SHOW ONLY IF CURRENCY = PESOS

    BUT I DONT KNOW HOW TO DO THAT!!!!!

    !"#$"#"!#%$

  • Please provide a sample of how the expected output should look.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • If I understood your question properly, the following query will work:

    SELECT * FROM ORDERS WHERE DATE IS NOT NULL

    and (CLIENT not in ('X','Y')

    or (CLIENT in ('X','Y') and CURRENCY = 'PESOS' ))

  • Or

    SELECT put column names here -- don't use select *

    FROM ORDERS

    WHERE DATE IS NOT NULL

    AND (CLIENT NOT IN ('X', 'Y')

    OR CURRENCY = 'PESOS') ;

    Regards,

    Willem
    http://wschampheleer.wordpress.com[/url]

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply