I'm getting the following error when trying to run the below custom SQL query against Amazon Redshift into Tableau desktop. I am able to "Preview" in Tableau but it does not work when I actually try to use this as a datasource.
[Amazon][RedShift ODBC] (30) Error occurred while trying to execute a query: ERROR: Invalid digit, Value 'L', Pos 0, Type: Double DETAIL: ----------------------------------------------- error: Invalid digit, Value 'L', Pos 0, Type: Double code: 1207 context: LNDL527501 query: 1611757 location: :0 process: query0_71 [pid=0] --------------------
SELECT d.dat, m.merch_id, q1.miles_purchased, q1.total_units,
CASE
WHEN date_diff('day'::text, m.first_trans::timestamp without time zone, d.dat::timestamp without time zone) < 0 THEN 0::bigint
ELSE date_diff('day'::text, m.first_trans::timestamp without time zone, d.dat::timestamp without time zone)
END AS days_open
FROM schemaname.all_dates d
CROSS JOIN ( SELECT t.merch_id, min(t.transaction_date)::date AS first_trans
FROM schemaname.transactions t
GROUP BY t.merch_id) m
LEFT JOIN ( SELECT t.merch_id, t.transaction_date::date AS trans_date, sum(t.settlement_amt) / 16.5 * 60::numeric AS miles_purchased, sum(t.settlement_amt) / 16.5 AS total_units
FROM schemaname.transactions t
GROUP BY t.merch_id, t.transaction_date::date) q1 ON m.merch_id::text = q1.merch_id::text AND d.dat = q1.trans_date;
- `List item`