[英]Sum Case when Sql
account_id revenue_2017 revenue_2018 acct_rev_growth
INTEGER DECIMAL DECIMAL DECIMAL
e.g. 123455 e.g. 1000.00 e.g. 1300.00 e.g. 0.30
account_id team region
INTEGER VARCHAR (25) VARCHAR (25)
e.g 46567 e.g Tech e.g. NAMER-US
在每個地區的一行中,顯示該地區、其 2018 年的技術團隊(團隊 = 'Tech')收入和 2018 年的 Edu 團隊(團隊 = 'Edu')收入。
要獲得每個地區和每個團隊,請將記錄分組到兩個字段中,然后計算每個組的總和。
select sum(table1.revenue_2018) as sum_2018
from table1
join table2 on table1.account_id = table2.account_id
group by table2.region, table2.team
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.