Hi, I am working on SQL and I don’t understand how the below statement does not work with ‘WITH’ and why are we not using ‘WITH’. If somebody can explain the difference, that would be great.
cross_join as(
SELECT *
from subscriptions
CROSS JOIN months
WITH months AS
(SELECT
'2017-01-01' as first_day,
'2017-01-31' as last_day
UNION
SELECT
'2017-02-01' as first_day,
'2017-02-28' as last_day
UNION
SELECT
'2017-03-01' as first_day,
'2017-03-31' as last_day
),
cross_join as(
SELECT *
from subscriptions
CROSS JOIN months
)
SELECT *
FROM cross_join
LIMIT 100;