select * from (select sum(Case When colposition=1 Then number1*Sign Else null End) as [a1], sum(Case When colposition=2 Then number1*Sign Else null End) as [a2], sum(Case When colposition=3 Then number1*Sign Else null End) as [a3], Supply, GoodsStyle, GoodsName, Units, ColorName, ColorCode, ColorValue, inPrice, SizeGroup, Sum(Number1*Sign) AS tNum, Sum(Number1*inPrice*Sign) AS tdpMon, Sum(Number1*Price*Sign) AS tMon,Case When Sum(Number1*Sign) is null then 0 Else Sum(Number1*InPrice*Sign)/Sum(Number1*Sign) End AS tPrice FROM vBillDetail where 1=1 and adddate<='2014-01-06' and depotname in ('衣铺二门店','衣铺一门店') GROUP BY Supply, GoodsStyle, GoodsName, Units, ColorName, ColorCode, ColorValue, inPrice, SizeGroup) where 1=1 order by GoodsStyle
在关键字 'where' 附近有语法错误。