select SUM(daycourse)as NUM1,tdate,line_name,bus_index from DayCourseRecord where %s and Event_Type is NULL group by tdate,line_name,bus_index
(%s表示查询条件 包含查询日期 、线路(默认全部) 、车号(默认全部))
查询的sql语句:
select SUM(Time_out-Time_in)as NUM,Date_Sign,bus_index from Attendance where 1=1 and Time_out!=86400 group by Date_Sign,bus_index
车辆模式——所有事件里程、时间
查询的sql语句:
select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,bus_index from DayCourseRecord where %s and Event_Type is NOT NULL and etime!=86400 group by tdate,line_name,bus_index
车辆模式——包车事件里程、时间
查询的sql语句:
select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,bus_index from DayCourseRecord where %s and Event_Type ='包车' and etime!=86400 group by tdate,line_name,bus_index
车辆模式——总里程(带有车辆名称)
查询的sql语句:
select DayCourseRecord.TDate,DayCourseRecord.Line_Name,DayCourseRecord.Bus_Index,BusInfo.BusName,SUM(daycourse) as NUM1 from DayCourseRecord,BusInfo
where 1=1 and DayCourseRecord.Bus_Index = BusInfo.BusIndex and Bus_Index !='' and Event_Type is NULL
group by DayCourseRecord.TDate,DayCourseRecord.Line_Name,DayCourseRecord.Bus_Index,BusInfo.BusName
相应配置如下:
注意增加相应的关联关系
司机模式——总里程
查询的sql语句:
select SUM(daycourse)as NUM1,tdate,line_name, Driver_Num from DayCourseRecord where %s and Driver_Num !='' and Event_Type is NULL group by tdate,line_name ,Driver_Num
(%s表示查询条件 包含查询日期 、线路(默认全部) 、司机(所选线路下的))
司机模式——运营时间
查询的sql语句:
select SUM(Time_out-Time_in)as NUM,Date_Sign,EmpNum from Attendance where %s and Time_out!=86400 group by Date_Sign,EmpNum
司机模式——所有事件里程、时间
查询的sql语句:
select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,Driver_Num from DayCourseRecord where %s and Event_Type is NOT NULL and etime!=86400 group by tdate,line_name,Driver_Num
司机模式——包车事件里程、时间
查询的sql语句:
select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name, Driver_Num from DayCourseRecord where 1=1 and Event_Type ='包车' and etime!=86400 group by tdate,line_name,Driver_Num
司机模式——总里程(带司机名称)
查询的sql语句:
select DayCourseRecord.TDate,DayCourseRecord.Line_Name,DayCourseRecord.Driver_Num,Employee.Employee_Name, SUM(daycourse) as NUM1
from DayCourseRecord,Employee where 1=1 and DayCourseRecord.Driver_Num = Employee.Employee_Num and Driver_Num !='' and Event_Type is NULL
group by DayCourseRecord.TDate,DayCourseRecord.Line_Name,DayCourseRecord.Driver_Num,Employee.Employee_Name
自定义汇总的配置
车辆模式——汇总查询
查询的sql语句:
select a.NUM1 as Daycourse,a.TDate,a.Line_Name,a.Bus_Index,b.NUM as iTime,c.NUM1 as EventCourse,c.NUM2 as EventTime,d.NUM1 as BaoCheCourse,d.NUM2 as BaoCheTime from
(select SUM(daycourse)as NUM1,tdate,line_name,bus_index from DayCourseRecord where 1=1 and Event_Type is NULL group by tdate,line_name,bus_index )a
left join
(select SUM(Time_out-Time_in)as NUM,Date_Sign,bus_index from Attendance where Time_out!=86400 group by Date_Sign,bus_index)b
on 1=1 and a.tdate = b.Date_Sign and a.bus_index = b.bus_index
left join
(select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,bus_index from DayCourseRecord where Event_Type is NOT NULL and etime!=86400 group by tdate,line_name,bus_index
)c on a.TDate = c.TDate and a.Bus_Index = c.Bus_Index
left join
(select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,bus_index from DayCourseRecord where Event_Type ='包车' and etime!=86400 group by tdate,line_name,bus_index )d
on a.TDate = d.TDate and a.Bus_Index = d.Bus_Index
where a. tdate = '20180603'
(%s表示查询条件 包含查询日期 、线路(默认全部) 、司机(所选线路下的))
select a.NUM1 as Daycourse,a.TDate,a.Line_Name,a.Driver_Num,b.NUM as iTime,c.NUM1 as EventCourse,c.NUM2 as EventTime,d.NUM1 as BaoCheCourse,d.NUM2 as BaoCheTime from
(select SUM(daycourse)as NUM1,tdate,line_name, Driver_Num from DayCourseRecord where %s and Driver_Num !='' and Event_Type is NULL group by tdate,line_name ,Driver_Num )a
left join
(select SUM(Time_out-Time_in)as NUM,Date_Sign,EmpNum from Attendance where Time_out!=86400 group by Date_Sign,EmpNum)b
on a.tdate = b.Date_Sign and a.Driver_Num = b.EmpNum
left join
(select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name,Driver_Num from DayCourseRecord where Event_Type is NOT NULL and etime!=86400 group by tdate,line_name,Driver_Num
)c on a.TDate = c.TDate and a.Driver_Num = c.Driver_Num
left join
(select SUM(daycourse)as NUM1,SUM(etime-stime)as NUM2,tdate,line_name, Driver_Num from DayCourseRecord where Event_Type ='包车' and etime!=86400 group by tdate,line_name,Driver_Num )d
on a.TDate = d.TDate and a.Driver_Num = d.Driver_Num
配置如下:
选择关联表
2. 设置显示列
设置查询条件
车辆模式——总里程(月份汇总)
查询的sql语句:
select Row_Number() OVER(order by [v_carName_zonglicheng].Line_Name) as RowId , [v_carName_zonglicheng].Line_Name,[v_carName_zonglicheng].Bus_Index,[v_carName_zonglicheng].BusName,sum(NUM1) as hz,LEFT(tdate,6) as riqi,max(case 't'+RIGHT(tdate,2) when 't01' then ISNULL(NUM1,0) else 0 end) 't01' ,max(case 't'+RIGHT(tdate,2) when 't02' then ISNULL(NUM1,0) else 0 end) 't02' ,max(case 't'+RIGHT(tdate,2) when 't03' then ISNULL(NUM1,0) else 0 end) 't03' ,max(case 't'+RIGHT(tdate,2) when 't04' then ISNULL(NUM1,0) else 0 end) 't04' ,max(case 't'+RIGHT(tdate,2) when 't05' then ISNULL(NUM1,0) else 0 end) 't05' ,max(case 't'+RIGHT(tdate,2) when 't06' then ISNULL(NUM1,0) else 0 end) 't06' ,max(case 't'+RIGHT(tdate,2) when 't07' then ISNULL(NUM1,0) else 0 end) 't07' ,max(case 't'+RIGHT(tdate,2) when 't08' then ISNULL(NUM1,0) else 0 end) 't08' ,max(case 't'+RIGHT(tdate,2) when 't09' then ISNULL(NUM1,0) else 0 end) 't09' ,max(case 't'+RIGHT(tdate,2) when 't10' then ISNULL(NUM1,0) else 0 end) 't10' ,max(case 't'+RIGHT(tdate,2) when 't11' then ISNULL(NUM1,0) else 0 end) 't11' ,max(case 't'+RIGHT(tdate,2) when 't12' then ISNULL(NUM1,0) else 0 end) 't12' ,max(case 't'+RIGHT(tdate,2) when 't13' then ISNULL(NUM1,0) else 0 end) 't13' ,max(case 't'+RIGHT(tdate,2) when 't14' then ISNULL(NUM1,0) else 0 end) 't14' ,max(case 't'+RIGHT(tdate,2) when 't15' then ISNULL(NUM1,0) else 0 end) 't15' ,max(case 't'+RIGHT(tdate,2) when 't16' then ISNULL(NUM1,0) else 0 end) 't16' ,max(case 't'+RIGHT(tdate,2) when 't17' then ISNULL(NUM1,0) else 0 end) 't17' ,max(case 't'+RIGHT(tdate,2) when 't18' then ISNULL(NUM1,0) else 0 end) 't18' ,max(case 't'+RIGHT(tdate,2) when 't19' then ISNULL(NUM1,0) else 0 end) 't19' ,max(case 't'+RIGHT(tdate,2) when 't20' then ISNULL(NUM1,0) else 0 end) 't20' ,max(case 't'+RIGHT(tdate,2) when 't21' then ISNULL(NUM1,0) else 0 end) 't21' ,max(case 't'+RIGHT(tdate,2) when 't22' then ISNULL(NUM1,0) else 0 end) 't22' ,max(case 't'+RIGHT(tdate,2) when 't23' then ISNULL(NUM1,0) else 0 end) 't23' ,max(case 't'+RIGHT(tdate,2) when 't24' then ISNULL(NUM1,0) else 0 end) 't24' ,max(case 't'+RIGHT(tdate,2) when 't25' then ISNULL(NUM1,0) else 0 end) 't25' ,max(case 't'+RIGHT(tdate,2) when 't26' then ISNULL(NUM1,0) else 0 end) 't26' ,max(case 't'+RIGHT(tdate,2) when 't27' then ISNULL(NUM1,0) else 0 end) 't27' ,max(case 't'+RIGHT(tdate,2) when 't28' then ISNULL(NUM1,0) else 0 end) 't28' ,max(case 't'+RIGHT(tdate,2) when 't29' then ISNULL(NUM1,0) else 0 end) 't29' ,max(case 't'+RIGHT(tdate,2) when 't30' then ISNULL(NUM1,0) else 0 end) 't30' ,max(case 't'+RIGHT(tdate,2) when 't31' then ISNULL(NUM1,0) else 0 end) 't31' from [v_carName_zonglicheng] where 1=1 group by [v_carName_zonglicheng].Line_Name,[v_carName_zonglicheng].Bus_Index,[v_carName_zonglicheng].BusName,LEFT(tdate,6)