首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

没有为第 1 列(属于 'A')指定列。如何修改了

2012-06-27 
没有为第 1 列(属于 A)指定列。怎么修改了select time coalesce(year(a.sale_addtime),year(b.saleout_

没有为第 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 

热点排行