---彙總並計算資料,通過他們共同屬性字段時間彙總計算資料得到結果
select a.oprate_time,convert(decimal(18,2),isnull((a.oprate_amount+isnull(b.oprate_amount,0)),0)) as hasmoney,convert(decimal(18,2),isnull(b.oprate_amount,0)) as cancelpaid,convert(decimal(18,2),isnull(c.oprate_amount,0)) as outpaid,convert(decimal(18,2),isnull(d.oprate_amount,0)) as refundpaid,convert(decimal(18,2),isnull((c.oprate_cbj-d.oprate_cbj),0)) as tatcb,(convert(decimal(18,2),isnull(c.oprate_amount,0))-convert(decimal(18,2),isnull(d.oprate_amount,0))-convert(decimal(18,2),isnull((c.oprate_cbj-d.oprate_cbj),0))) as ml,isnull((convert(decimal(18,2),(convert(decimal(18,2),isnull(c.oprate_amount,0))-convert(decimal(18,2),isnull(d.oprate_amount,0))-convert(decimal(18,2),isnull((c.oprate_cbj-d.oprate_cbj),0)))/(c.oprate_amount-d.oprate_amount),2)),0) as mll,isnull((convert(decimal(18,2),(case when b.oprate_amount*(a.oprate_amount+isnull(b.oprate_amount,0)) =0 then 0 else b.oprate_amount/(a.oprate_amount+isnull(b.oprate_amount,0)) end),2)),0) as cancelorder,isnull((convert(decimal(18,2),(case when d.oprate_amount*(a.oprate_amount+isnull(b.oprate_amount,0)) =0 then 0 else d.oprate_amount/(a.oprate_amount+isnull(b.oprate_amount,0)) end),2)),0) as refundorder,isnull((convert(decimal(18,2),(case when c.oprate_amount*(a.oprate_amount+isnull(b.oprate_amount,0)) =0 then 0 else c.oprate_amount/(a.oprate_amount+isnull(b.oprate_amount,0)) end),2)),0) as outorder
---查詢型別為a的資料根據時間彙總並且把它當成一張表
from (select a.oprate_time,sum(a.oprate_amount) as oprate_amount,sum(a.oprate_cbj) as oprate_cbj from (select distinct a.shop_no,a.oprate_time,a.oprate_amount,a.oprate_cbj,a.oprate_code,a.order_no,a.spec_no,a.spec_no_sale from dbo.oprate_data a where a.oprate_code='a' )a group by a.oprate_time)a
left join
--- 查詢取消金額查詢型別為b的資料根據時間彙總並且把它當成一張表
(select count(1) as ordernum ,a.oprate_time,sum(a.oprate_amount) as oprate_amount,sum(a.oprate_cbj) as oprate_cbj from (select distinct a.shop_no,a.oprate_time,a.oprate_amount,a.oprate_cbj,a.oprate_code,a.order_no from dbo.oprate_data a where a.oprate_code='b' )a group by a.oprate_time)b
on a.oprate_time=b.oprate_time
----查詢出庫訂單金額查詢型別為c的資料根據時間彙總並且把它當成一張表
left join
(select count(1) as ordernum ,a.oprate_time,sum(a.oprate_amount) as oprate_amount,sum(a.oprate_cbj) as oprate_cbj from (select distinct a.shop_no,a.oprate_time,a.oprate_amount,a.oprate_cbj,a.oprate_code,a.order_no from dbo.oprate_data a where a.oprate_code='c' )a group by a.oprate_time)c
on b.oprate_time=c.oprate_time
---查詢銷售退貨金額查詢型別為d的資料根據時間彙總並且把它當成一張表
left join
(select count(1) as ordernum ,a.oprate_time,sum(a.oprate_amount) as oprate_amount,sum(a.oprate_cbj) as oprate_cbj from (select distinct a.shop_no,a.oprate_time,a.oprate_amount,a.oprate_cbj,a.oprate_code,a.order_no from dbo.oprate_data a where a.oprate_code='d' )a group by a.oprate_time)d
on c.oprate_time = d.oprate_time order by a.oprate_time desc
最後歡迎各位同學交流指導... ...
oracle sql 中不同型別的表連線
1 full join 2 inner join 3 outer join left outer join right outer join full join 匹配的結果與所有左邊的表中不匹配右邊的行和右邊的表中所有不匹配左邊的行加在一起,在不匹配的地方使用null代替。結果行數 匹配行數 左表剩...
hive,操作庫 不同型別的表
hive中有乙個預設的庫 庫名 default 庫目錄 hdfs hdp20 01 9000 user hive warehouse create database db order 庫建好後,在hdfs中會生成乙個庫目錄 hdfs hdp20 01 9000 user hive warehouse...
CSS 為不同型別的裝置建立樣式表
針對要顯示的頁面型別 桌面pc,筆記本,平板,手機,頁面的印刷版本 方法一 在html中利用,新增media屬性 media screen and max device width 480px rel stylesheet href 檔名.css type text css 類似,可建立乙個查詢來匹...