select a.*,b.start_time,b.end_time,sum(a.n1) as cn1_total, sum(a.n2)  as n2_total,sum(a.n3)  as n3_total,sum(a.n4)  as n4_totalfrom oil_record a,oil_record1 b 
where (a.idno=b.idno)
这个语句哪里有问题?怎么改?

解决方案 »

  1.   

    select
     a.*,b.start_time,b.end_time,
     sum(a.n1) as cn1_total,
     sum(a.n2) as n2_total,
     sum(a.n3) as n3_total,
     sum(a.n4) as n4_total
    from
     oil_record a,oil_record1 b 
    where
     a.idno=b.idno
    group by
     a的所有字段 ,b.start_time,b.end_time
      

  2.   

    select a.*,b.start_time,b.end_time,sum(a.n1) as cn1_total, sum(a.n2) as n2_total,sum(a.n3) as n3_total,sum(a.n4) as n4_totalfrom oil_record a,oil_record1 b 
    where (a.idno=b.idno)
    group by a.*,b.start_time,b.end_time
      

  3.   

    select a.*,b.start_time,b.end_time,sum(a.n1) as cn1_total, sum(a.n2) as n2_total,sum(a.n3) as n3_total,sum(a.n4) as n4_totalfrom oil_record a,oil_record1 b 
    where (a.idno=b.idno)
    group by a.*,b.start_time,b.end_time[code=SQL]
    红色部分可能要换成具体字段