销售统计(一列今日量,一列累计量)
饮品/门店 | 门店1 | 门店2 | 累计销量 |
可乐 | 10 | 10 | 20 |
雪碧 | 20 | 30 | 80 |
Select ProductCode ,ShopNo,sum(case when MakeTime like '%2017-12-12%' then TotalSalesOrderAmount end) as '本日',
sum(case when MakeTime < '2017-12-12 00:00:00' then TotalSalesOrderAmount end) as '累计' from DMS_TotalSalesOrder
group by ProductCode ,ShopNo
修改时间字段的部分内容
--修改d表日期字段的年份
update [test].[dbo].[L_AlarmLog]
set Operatetime=STUFF(convert(nvarchar(23),Operatetime,120),1,4,'2012')
--修改d表日期字段的月份
update [test].[dbo].[L_AlarmLog]
set Operatetime=STUFF(convert(nvarchar(23),Operatetime,120),6,2,'3')
--修改d表日期字段的天数
update [test].[dbo].[L_AlarmLog]
set Operatetime=STUFF(convert(nvarchar(23),Operatetime,120),9,2,'25')
--修改d表日期字段的小时数
update [test].[dbo].[L_AlarmLog]
set Operatetime =STUFF(convert(nvarchar(23),Operatetime,120),12,2,'9')
--修改d表日期字段的分钟数
update [test].[dbo].[L_AlarmLog]
set Operatetime =STUFF(convert(nvarchar(23),Operatetime,120),15,2,'15')
--修改d表日期字段的秒数
update [test].[dbo].[L_AlarmLog]
set Operatetime =STUFF(convert(nvarchar(23),Operatetime,120),18,2,'30')
--修改d表日期字段的年份、小时
update [test].[dbo].[L_AlarmLog]
set Operatetime=Convert(datetime,stuff(STUFF(Convert(char,Operatetime,120), 1,4, '2011'),12,2, '02'))
--修改表日期字段的年份
update TimingSaveVolume set OilQty = cast(rand(checksum(newid()))*(100005-100000)+100000 as float(6))