AndrewMo
AndrewMo

Reputation: 149

SQL Create dates between date range for multiple dimensions

I have two tables:

SELECT  DISTINCT ServLine,RoomID,StartDt,EndDt
INTO    #raw
FROM    table

SELECT  CALENDAR_DATE
INTO    #cal
FROM    caldendar

How would I write a query to show each CALENDAR_DATE from the #cal table that is in between each StartDt and EndDt for each RoomID and ServLine from the #raw table.

Thank you

Upvotes: 2

Views: 112

Answers (1)

SqlZim
SqlZim

Reputation: 38053

With a join. Depending on exactly what input and desired output you have, the join may vary, but an inner join seems like a good place to start without more information.

select *
from #raw r
  inner join #cal c
    on c.date >= r.startdt
   and c.date <= r.enddt

Upvotes: 2

Related Questions