Sub query runs by its self, full query wont

UDA
Enthusiast

Sub query runs by its self, full query wont



Im getting an error expecting something between year and i dont understand whats causing it. when i run each sub query they run, when i put them in the big query together it errors out

SELECT *
FROM edw_access_views.calendar cal
WHERE cal.calendar_date = YEAR(CURRENT_DATE)||'-'||'01'||'-'||'01'
)
AND (
SELECT MAX(calendar_date)
FROM edw_access_views.calendar cal
WHERE (cal.calendar_date BETWEEN YEAR(CURRENT_DATE)||'-'||'01'||'-'||'01' AND CURRENT_DATE)
)
OR cal.calendar_date BETWEEN (
SELECT MIN(calendar_date)
FROM edw_access_views.calendar cal
WHERE (cal.calendar_date BETWEEN YEAR(CURRENT_DATE)-1||'-'||'01'||'-'||'01' AND CURRENT_DATE-365)
)
AND (
SELECT MIN(calendar_date)
FROM edw_access_views.calendar cal
WHERE (cal.calendar_date BETWEEN YEAR(CURRENT_DATE)-1||'-'||'01'||'-'||'01' AND CURRENT_DATE-365)
)
1 REPLY
Enthusiast

Re: Sub query runs by its self, full query wont

Can you share what is the error number?