日期:2014-05-18 浏览次数:20764 次
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