Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Need help in getting SQL query Expand / Collapse
Author
Message
Posted Saturday, March 22, 2014 10:37 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Saturday, March 22, 2014 11:31 PM
Points: 1, Visits: 2
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
Post #1553791
Posted Saturday, March 22, 2014 11:52 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 12:07 AM
Points: 38,005, Visits: 34,917
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1553795
Posted Monday, March 24, 2014 9:08 AM


Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Yesterday @ 4:51 PM
Points: 709, Visits: 7,290
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?
Post #1554084
Posted Wednesday, March 26, 2014 12:51 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 4, 2014 11:13 PM
Points: 4, Visits: 6
Select Emp_ID from table_Name where Flag='yes' and processing_date='Old Date'
Post #1554789
Posted Wednesday, March 26, 2014 12:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, June 4, 2014 11:13 PM
Points: 4, Visits: 6
Select Emp_ID from table_Name where Flag='yes' and Processing_Date='Old Date'
Post #1554790
Posted Friday, April 25, 2014 8:29 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, August 12, 2014 1:13 AM
Points: 4, Visits: 30


select empid from tablename where flag='yes' and processingdate='old date'
Post #1565117
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse