Need help in getting SQL query

  • Hi All,

    Need your help on getting the sql query for the below data

    EMP ID Flag Processing Date

    ABC1 yes Current Date

    ABC1 No Old Date

    DEF1 Yes Current Date

    DEF1 No Old Date

    GHI1 Yes Old Date

    JKL1 yes Current Date

    JKL1 No Old Date

    i need to select only EMP ID for the above table for which Flag is set to Yes and Processing Date is old Date.

    Thank you

    Santosh

  • santuraj12 (3/22/2014)


    Hi All,

    Need your help on getting the sql query for the below data

    EMP ID Flag Processing Date

    ABC1 yes Current Date

    ABC1 No Old Date

    DEF1 Yes Current Date

    DEF1 No Old Date

    GHI1 Yes Old Date

    JKL1 yes Current Date

    JKL1 No Old Date

    i need to select only EMP ID for the above table for which Flag is set to Yes and Processing Date is old Date.

    Thank you

    Santosh

    Just add mostly what you said the a WHERE clause.

    --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)

  • Jeff Moden (3/22/2014)


    santuraj12 (3/22/2014)


    Hi All,

    Need your help on getting the sql query for the below data

    EMP ID Flag Processing Date

    ABC1 yes Current Date

    ABC1 No Old Date

    DEF1 Yes Current Date

    DEF1 No Old Date

    GHI1 Yes Old Date

    JKL1 yes Current Date

    JKL1 No Old Date

    i need to select only EMP ID for the above table for which Flag is set to Yes and Processing Date is old Date.

    Thank you

    Santosh

    Just add mostly what you said the a WHERE clause.

    And you might have to match the date format for GETDATE() to what is in your table.

    But I would question the actual design.

    What updates Current Date?

    If you wait a day, what happens?

  • Select Emp_ID from table_Name where Flag='yes' and processing_date='Old Date'

  • Select Emp_ID from table_Name where Flag='yes' and Processing_Date='Old Date'

  • select empid from tablename where flag='yes' and processingdate='old date'

Viewing 6 posts - 1 through 5 (of 5 total)

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