• prathibha_aviator (10/28/2012)


    Customer

    CustomerIDCustomerNameBirthdate

    1John Doe1/1/1970 08:31 AM

    2Jane Doe1/1/1971 01:18 PM

    3Jon Public1/1/1972 11:58 PM

    4Jane Public1/1/1973 07:00 AM

    5John Smith1/1/1974 08:31 AM

    Order

    OrderIDPO NumberOrderDate

    1000ABC1231/1/2012 01:00 PM

    20001122332/1/2012 02:00 AM

    3000XYZ9873/1/2012 03:00 PM

    4000500004/1/2012 04:00 AM

    5000Verbal5/1/2012 05:00 AM

    CustomerOrders

    CustomerIDOrderIDIsShipped

    11000False

    13000True

    34000False

    22000True

    55000True

    Question is

    Provide the sql statement that will return the PO Number if the CustomerID is greater than 3 and the OrderID if the CustomerID is 3 or less.

    Since this looks a whole lot like homework, I recommend that you take a look at the CASE statement in Books Online (the free help system that comes with SQL Server).

    Also, take a look at the first link in my signature line below. You'll get better answers that way.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)