select a.no,a.cou,b.je_2 from
(select no,sum(je_1) cou
from table_1
group by no) a
left join
(select no,je_2 from table_1 where rq='20060701') b
on a.no=b.no

解决方案 »

  1.   

    不好意思,看错了,是20060301select a.no,a.cou,b.je_2 from
    (select no,sum(je_1) cou
    from table_1
    group by no) a
    left join
    (select no,je_2 from table_1 where rq='20060301') b
    on a.no=b.no
      

  2.   

    SELECT NO,sum(je_1),substr(je_2,9)
    FROM(
    select no,(je_1),max(rq||je_2) over(PARTITION by NO ) je_2
    from table_1
    ) GROUP BY NO,substr(je_2,7)
      

  3.   

    select NO,sum(je_1),sum(case when rq='20060301' then 1 else 0 end)
    from table_1
    group by no
      

  4.   

    SELECT a.no, a.je, b.je
      FROM (SELECT   no, SUM (je_1) je
                FROM table_1
            GROUP BY no) a LEFT OUTER JOIN (SELECT   no, SUM (je_2) je
                                                 FROM table_1
                                                WHERE rq = '20060301'
                                             GROUP BY no) b ON (a.no = b.no)
           ;