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