现有表【订单】,字段名:[分公司],[订单量],[年],[月]。 SQL: select A.NAME,SUM(isnull(订单量,0)) [订单量],YEAR(Fdate) AS [年],MONTH(Fdate) AS [月] from A LEFT JOIN B ON(A.NAME = B.NAME) where FTranType = 21 AND B.billType='分公司' AND (FNumber like 'F00%' or FNumber like 'F01%' or FNumber like 'F11%') AND FROB !=-1 and Fdate>= '2016-11-01' group by A.NAME,YEAR(Fdate),MONTH(Fdate) 现在想要月份扩展的时候,下面可以出现前三个月订单数据和(例:月份为8的时候,下面对应的数据为5、6、7月订单数之和) |
最佳回答 |
||||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|
|||
0
|
|