SQLTeam.com | Weblogs | Forums

SQL Query Help


#1

I need help on below logic. I need to match all the records with current system date and display 1 if it is match and zero if it is not match with current system date based on the Client_Code.

Table:

Client_Code HolidayDate Year
Testing 2/15/2017 2017
Testing 3/12/2017 2017
Testing 5/23/2017 2017
Testing 6/12/2017 2017
Testing 7/9/2017 2017
Unilever 1/12/2017 2017
Unilever 2/17/2017 2017
Unilever 3/23/2017 2017
Unilever 2/21/2017 NULL

I need output like
Client_Code Status
Testing 0
Unilever 1

Please help me to solve this. Thanks in advance for your response.


#2

SELECT Client_Code, 1 AS Status
FROM table_name
WHERE HolidayDate = CAST(GETDATE() AS date)