读书人

没有为第 1 列(属于 #039;A#039;)指定列。如

发布时间: 2012-06-27 14:20:09 作者: rapoo

没有为第 1 列(属于 'A')指定列。怎么修改了
select time = coalesce(year(a.sale_addtime),year(b.saleout_addtime)),
salemoney = isnull(convert(decimal(18,2),a.sale_money), 0) from (select year(sale_addtime),sale_amount =sum(convert(decimal(18,2),c.item_amount)) from x_sale b left join x_saleitem c on c.item_sale=b.sale_code left join x_product d on d.pro_id=c.item_pro where 1=1 group by year(sale_addtime)) A full join (select year(saleout_addtime),saleout_amount =sum(convert(decimal(18,2),c.item_amount)) from x_saleout b left join x_saleoutitem c on c.item_saleout=b.saleout_code left join x_product d on d.pro_id=c.item_pro where 1=1 group by year(saleout_addtime)) B on A.sale_addtime = B.saleout_addtime

是什么原因了,我想按年综计实际销售数量,如2012,2013年等

[解决办法]

SQL code
select    time = coalesce(year(a.sale_addtime),year(b.saleout_addtime)),        salemoney = isnull(convert(decimal(18,2),a.sale_money), 0) from   (        select year(sale_addtime) AS col1,        sale_amount =sum(convert(decimal(18,2),c.item_amount))         from x_sale b    left join x_saleitem c on c.item_sale=b.sale_code                         left join x_product d on d.pro_id=c.item_pro         where 1=1 group by year(sale_addtime)) A         full join (select year(saleout_addtime) AS col2,saleout_amount =sum(convert(decimal(18,2),c.item_amount)) from x_saleout b left join x_saleoutitem c on c.item_saleout=b.saleout_code left join x_product d on d.pro_id=c.item_pro where 1=1 group by year(saleout_addtime)) B on A.sale_addtime = B.saleout_addtime 

读书人网 >SQL Server

热点推荐