0
Aginity SQLエディタで以下のクエリを実行して、結果を に対して表示できますが、カスタムSQLと同じクエリを使用してTableau報告書に「23行目または23行目でSQL.Syntaxエラーを実行しようとしたRedshift ODBSエラー; trans_amt < = 85;」というエラーが表示されるSQLはAginityで実行されていますが、Tableauでカスタムクエリとして拒否されました10.1
WITH cons_dedup AS
(SELECT DISTINCT * FROM shop.consumer)
SELECT
MAX(trans_amt) OVER (PARTITION BY trans.cardid) as max_transaction_for_card,
85 as full_tank,
trans_amt/MAX(trans_amt) OVER (PARTITION BY trans.cardid) as pct_of_max_transaction_for_card,
(CASE WHEN trans_amt/MAX(85) OVER (PARTITION BY trans.cardid) >= .6 THEN 'A'
WHEN trans_amt/MAX(85) OVER (PARTITION BY trans.cardid) >= .2 and trans_amt/MAX(85) OVER (PARTITION BY trans.cardid) <.6 THEN 'B'
WHEN trans_amt/MAX(85) OVER (PARTITION BY trans.cardid) >= 0 and trans_amt/MAX(85) OVER (PARTITION BY trans.cardid) <.2 THEN 'C'
ELSE 'Unknown' END) AS trans_category,
COUNT(*) OVER (PARTITION by trans.cardid) as cnt_trans_for_card,
MIN(transaction_date) OVER (PARTITION BY trans.cardid) as timestamp_of_first_trans_for_card,
LAG(transaction_date, 1) OVER (PARTITION BY trans.cardid ORDER BY transaction_date) as prev_trans_timestamp_for_card,
LEAD(transaction_date, 1) OVER (PARTITION BY trans.cardid ORDER BY transaction_date) as next_trans_timestamp_for_card,
DATEDIFF(day, LAG(transaction_date, 1) OVER (PARTITION BY trans.cardid ORDER BY transaction_date), transaction_date) as days_since_last_trans_for_card,
DATEDIFF(day, transaction_date, LEAD(transaction_date, 1) OVER (PARTITION BY trans.cardid ORDER BY transaction_date)) as days_until_next_trans_for_card,
DATEDIFF(day, transaction_date, MIN(transaction_date) OVER (PARTITION BY trans.cardid)) as days_since_first_trans,
trans.*,
cons.fullname
FROM x.transaction trans
INNER JOIN cons_dedup cons
ON trans.cardid = cons.cardid
WHERE transaction_desc LIKE 'Transaction Approved (Pre-authorization Advice%'
AND cons.fullname NOT IN ('SYZ', 'TTT')
AND trans_amt <= 85 and trans_amt >= 3;
おそらくあなたの二つのテーブルの1は右、それにtrans_amtという列を持っていますか?列データ型とは何ですか? –
最後から ';'を削除してみてください - これは私の経験でTableauに問題を引き起こすことがあります。 –