SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Need help in getting SQL query


Need help in getting SQL query

Author
Message
santuraj12
santuraj12
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
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
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)SSC Guru (87K reputation)

Group: General Forum Members
Points: 87886 Visits: 41124
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.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Greg Edwards-268690
Greg Edwards-268690
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1580 Visits: 8495
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?
davendrak49
davendrak49
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 6
Select Emp_ID from table_Name where Flag='yes' and processing_date='Old Date'
davendrak49
davendrak49
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 6
Select Emp_ID from table_Name where Flag='yes' and Processing_Date='Old Date'
sekhar.kandregula
sekhar.kandregula
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 30
select empid from tablename where flag='yes' and processingdate='old date'
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search