--try,用union 或者union all 合并的表,每一个字段类型要一致,字段个数要相等!
select convert(varchar(10),dkrq,120) 到款日期,wpdm as 物品代码,count(distinct bh) as 总货物数,sum(wpjg) as 物品价格,sum(yf) as 邮费,sum(bxf) as 保修费,sum(zj) as 总价
from orders 
where dkrq between '2005-11-1' and '2005-11-12'group by dkrq,wpdm order by dkrq,wpdm
union all
select '小计',count(distinct wpdm),count(distinct bh),sum(wpjg),sum(yf),sum(bxf),sum(zj) 
from orders 
where dkrq between '2005-11-1' and '2005-11-12' group by dkrq 

解决方案 »

  1.   

    order by 放後面
    select dkrq 到款日期,wpdm as 物品代码,count(distinct bh) as 总货物数,sum(wpjg) as 物品价格,sum(yf) as 邮费,sum(bxf) as 保修费,sum(zj) as 总价
    from orders 
    where dkrq between '2005-11-1' and '2005-11-12'group by dkrq,wpdm
    union all
    select '小计',count(distinct wpdm),count(distinct bh),sum(wpjg),sum(yf),sum(bxf),sum(zj) 
    from orders 
    where dkrq between '2005-11-1' and '2005-11-12' group by dkrq 
     order by dkrq,wpdm
      

  2.   

    --恩。也不支持 order by 每一个查询记录