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
时间: 2024-10-02 07:00:34