Reputation: 170
I need to get the number of holidays between two dates. I have tried using the query below but I'm getting the following error
Incorrect syntax near the keyword 'FROM'.
SELECT STEP_ONE, STEP_TWO,
COUNT(*) FROM HOLIDAY_TB AS h WHERE h.HOLIDAY_DATE BETWEEN STEP_ONE AND
STEP_TWO FROM datesTest
Here is the Holidays Table. DOW is the Day of the Week.
HOLIDAY_TB
Here is the dates table with steps.
datesTest
Upvotes: 0
Views: 633
Reputation: 37473
You can try below -
SELECT STEP_ONE, STEP_TWO,
COUNT(*) FROM HOLIDAY_TB AS h inner join datesTest
on h.HOLIDAY_DATE>=STEP_ONE AND h.HOLIDAY_DATE<=STEP_TWO
group by STEP_ONE, STEP_TWO
Upvotes: 3