0
這是我的查詢:豐富表
SELECT
a.account_type AS ACCOUNT_TYPE
,b.at_account_type_desc
,COUNT(a.BAN) AS num_BAN
FROM csm_adx.billing_account_act AS a
LEFT OUTER JOIN csm_adx.account_type_act AS b ON a.account_type = b.at_acc_type
GROUP BY 1,2
現在我想將它連接到其中包含的信息另一個表TABLE_C的帳戶:暫定,取消,關閉,暫停開放。
我想我的結果表包含aditional的三列:ACTIVE_BAN
,SUSPENDED_BAN
和CANCELLED_BAN
每個數值包含當前活動,暫停和取消禁令的數量。我正在使用Teradata。
你能幫我做這個嗎?
這是當表與包含BAN狀態的另一個表連接的結果:
SELECT
a.account_type AS ACCOUNT_TYPE
,b.at_account_type_desc
,c.description
,COUNT(a.BAN) AS num_BAN
FROM csm_adx.billing_account_act AS a
LEFT OUTER JOIN csm_adx.account_type_act AS b
ON a.account_type = b.at_acc_type
LEFT OUTER JOIN csm_adx.acct_status AS c
ON a.ban_status = c.original_status_code
GROUP BY 1,2,3
完美!謝謝 :) – Dantes