Christopher Kinyua
Christopher Kinyua

Reputation: 170

Select count of holidays between two dates

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

enter image description here

Here is the dates table with steps.

datesTest

enter image description here

Upvotes: 0

Views: 633

Answers (1)

Fahmi
Fahmi

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

Related Questions