首页 > 代码库 > SQL Server 按月统计订单量

SQL Server 按月统计订单量

Use Basketselect convert(varchar(7),Orderdate,120) as YearMonth,OrderID,TotalCostinto #afrom Basket.dbo.BaseOrderTracker(nolock)where OrderDate >=‘2013-07-01‘and OrderDate <=‘2014-07-31‘and OrderTypeID = 15and OESourceID = 2and StageID= 10400select * from #aselect YearMonth,COUNT(distinct OrderID),SUM(TotalCost)from #a (nolock)group by YearMonthdrop table #a

  

SQL Server 按月统计订单量