笔记192 油品销售统计汇总报表的sql语句解析

笔记192 油品销售统计汇总报表的sql语句解析

 1 --油品销售统计汇总报表的sql语句解析
 2 /*isnull(check_expression , replacement_value )
 3 语法
 4 ISNULL ( check_expression , replacement_value )
 5 参数
 6 check_expression
 7 将被检查是否为 NULL的表达式。check_expression 可以是任何类型的。
 8 replacement_value
 9 在 check_expression 为 NULL时将返回的表达式。replacement_value 必须与 check_expresssion 具有相同的类型。
10 返回类型
11 返回与 check_expression 相同的类型。
12 注释
13 如果 check_expression 不为 NULL,那么返回该表达式的值;否则返回 replacement_value。
14 */
15 
16 
17 
18 
19 select
20 isnull(c.StationName,'''') as StationName,
21 a.VC_FD_OilType as OilType,
22 a.I_FD_TypeCode as CardType,
23 sum(a.DE_FD_Amount) as AMount,
24 Sum(a.DE_FD_Volume) as Volume,
25 isnull(sum(a.DE_FD_Volume*b.StandardDensity*(b.CorrectCoefficient-0.0011)),0) as FuelVolume
26 
27 from
28 
29 CT_Fuelingdata a left join Sys_Measure b on b.stationno=a.I_FD_StationNO and b.PumpID=a.I_FD_PumpID
30 left join Sys_StationInfor c on c.StationNO=a.I_FD_StationNO
31 
32 where
33 
34 8=8 and b.VC_OC_CardNO='2' and a.VC_FD_OilType='2' and a.I_FD_TypeCode=2 and a.I_FD_StationNo=1 and a.d_FD_Datetime>='2012-03-25' and a.d_FD_Datetime<='2012-03-26'
35 
36 group by
37 
38 a.I_FD_StationNO,a.VC_FD_OilType,a.I_FD_TypeCode,c.StationName
39 
40 order by
41 
42 a.VC_FD_OilType,c.StationName

 

posted @ 2013-08-04 13:07  桦仔  阅读(567)  评论(0编辑  收藏  举报