mysql 金额 类型,SQL实现根据类型对金额进行归类
搜索熱詞
下面是編程之家 jb51.cc 通過網絡收集整理的代碼片段。
編程之家小編現在分享給大家,也給大家做個參考。
select
temp.id,sum(temp.typyA_amount) as typyA_amount,sum(temp.typyB_amount) as typyB_amount,sum(temp.typyC_amount) as typyC_amount,sum(temp.typyD_amount) as typyD_amount
from
(select t.id,sum(t.A) as typyA_amount --A,null as typyB_amount --B,null as typyC_amount --C,null as typyD_amount --D
from table t
where t.type ='A'
group by t.id
union all
select t.id,null as typyA_amount --A,sum(t.B) as typyB_amount --B,null as typyD_amount --D
from table t
where t.type ='B'
group by t.id
union all
select t.id,sum(t.C) as typyC_amount --C,null as typyD_amount --D
from table t
where t.type ='C'
group by t.id
union all
select t.id,sum(t.D) as typyD_amount --D
from table t
where t.type ='D'
group by t.id) temp
以上是編程之家(jb51.cc)為你收集整理的全部代碼內容,希望文章能夠幫你解決所遇到的程序開發問題。
如果覺得編程之家網站內容還不錯,歡迎將編程之家網站推薦給程序員好友。
總結
以上是編程之家為你收集整理的SQL實現根據類型對金額進行歸類全部內容,希望文章能夠幫你解決SQL實現根據類型對金額進行歸類所遇到的程序開發問題。
如果覺得編程之家網站內容還不錯,歡迎將編程之家網站推薦給程序員好友。
本圖文內容來源于網友網絡收集整理提供,作為學習參考使用,版權屬于原作者。
總結
以上是生活随笔為你收集整理的mysql 金额 类型,SQL实现根据类型对金额进行归类的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: php左边按钮右边显示,右侧操作按钮
- 下一篇: usd php 换算,货币在PHP中从I