SQL Server 按月统计订单量
时间:2014-08-29 17:51:10
收藏:0
阅读:250
Use Basket select convert(varchar(7),Orderdate,120) as YearMonth ,OrderID ,TotalCost into #a from Basket.dbo.BaseOrderTracker(nolock) where OrderDate >=‘2013-07-01‘ and OrderDate <=‘2014-07-31‘ and OrderTypeID = 15 and OESourceID = 2 and StageID= 10400 select * from #a select YearMonth, COUNT(distinct OrderID), SUM(TotalCost) from #a (nolock) group by YearMonth drop table #a
原文:http://www.cnblogs.com/monkeyfather/p/3945352.html
评论(0)