我是新的tableau參數。我試圖執行以下查詢,但不知何故,它給了我缺少括號錯誤。案例陳述客戶查詢
SELECT
CASE
WHEN <Parameters.Timeframe> = 'YTD'
THEN TO_CHAR(to_date('01-JAN-' || to_char(sysdate, 'YYYY'), 'dd-mon-yyyy'))
WHEN <Parameters.Timeframe> = 'MTD'
THEN TO_CHAR(TO_DATE('01-' || TO_CHAR(SYSDATE,'MON-YYYY'),'DD-MON-YYYY'))
WHEN <Parameters.Timeframe> = 'QTD' and TO_CHAR(SYSDATE,'Q') = 1
THEN TO_CHAR(TO_DATE('01-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY'))
WHEN <Parameters.Timeframe> = 'QTD' and TO_CHAR(SYSDATE,'Q') = 2
THEN TO_CHAR(TO_DATE('04-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY'))
WHEN <Parameters.Timeframe> = 'QTD' and TO_CHAR(SYSDATE,'Q') = 3
THEN TO_CHAR(TO_DATE('07-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY'))
WHEN <Parameters.Timeframe> = 'QTD' and TO_CHAR(SYSDATE,'Q') = 4
THEN TO_CHAR(TO_DATE('10-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY'))
ELSE
TO_CHAR(SYSDATE)
END as DATE_RANGE_START
FROM table a
where
a.created_date >= CASE
WHEN <Parameters.Timeframe> = 'YTD'
THEN to_date('01-JAN-' || to_char(sysdate, 'YYYY'), 'dd-mon-yyyy')
WHEN <Parameters.Timeframe> = 'MTD'
THEN TO_DATE('01-' || TO_CHAR(SYSDATE,'MON-YYYY'),'DD-MON-YYYY')
WHEN <Parameters.Timeframe> = 'QTD' and TO_CHAR(SYSDATE,'Q') = 1
THEN TO_DATE('01-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY')
WHEN <Parameters.Timeframe> = 'QTD' and TO_CHAR(SYSDATE,'Q') = 2
THEN TO_DATE('04-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY')
WHEN <Parameters.Timeframe> = 'QTD' and TO_CHAR(SYSDATE,'Q') = 3
THEN TO_DATE('07-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY')
WHEN <Parameters.Timeframe> = 'QTD' and TO_CHAR(SYSDATE,'Q') = 4
THEN TO_DATE('10-01-' || TO_CHAR(SYSDATE,'YYYY'),'MM-DD-YYYY')
ELSE
SYSDATE
END
and a.created_date <= sysdate
我應該如何修復它
這是不是讓你在那裏的失敗行號的WHERE和HAVING子句? – Ageonix
請發佈完整的錯誤堆棧 – MaxU
查找並閱讀日誌。它會向您顯示Tableau嘗試運行的確切查詢。 Tableau傳遞給查詢的參數值始終可能不是正確的格式,等等。 – Nicarus