我的目标是将所有3行连接到一行.我试图只回到1行.
Run Code Online (Sandbox Code Playgroud)select br_data.acct_id , bs_accts.acct_num, case br_data.recmethod when 1 then count(br_data.recmethod) else 0 end as "Open", case br_data.recmethod when 2 then count(br_data.recmethod) else 0 end as "Closed", case br_data.recmethod when 0 then count(br_data.recmethod) else 0 as "Suspended" from br_data , bs_accts where br_data.acct_id = bs_accts.acct_id and br_data.acct_id = '427' group by br_data.acct_id , bs_accts.acct_num , br_data.recmethod order by br_data.acct_id
目前的结果:
Run Code Online (Sandbox Code Playgroud)acct_id acct_num open closed suspended 427 0060-1537100-OLD 0 0 376818 427 0060-1537100-OLD 2279474 0 0 427 0060-1537100-OLD 0 82675 0 …