select 单据号,日期,sum(金额) from 表1,表2 where 表1.单据号 = 表2.单据号
group by 单据号,日期

解决方案 »

  1.   

    select a.单据号,a.日期,b.金额 from 表1 a,
    (select sum(总价) 金额,单据号 from 表2 group by 单据号) b
    where a.单据号 = b.单据号;
      

  2.   

    这样当然能行,但实际上表1中有好多的字段,我都要选择,那岂不都要加在group by后了。这种方法我知道,有没更好的方法,不要嵌套。