Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2004
    Posts
    1

    Unanswered: oracle <left outer join> problem !

    PHP Code:
    select d.deptnocount(empno)
    from dept d left outer join emp e
    on d
    .deptno e.deptno
    group by d
    .deptno 
    the output will be like that:
    deptno | count(empno)
    ----------------------
    D1 | 2
    D2 | 3
    D3 | 0
    but if i want to show the dname too, result want to be like that:
    deptno | dname | count(empno)
    ----------------------
    D1 | sales | 2
    D2 | account | 3
    D3 | research | 0
    what is the correct method, the following can't work
    PHP Code:
    select d.deptnod.dnamecount(empno)
    from dept d left outer join emp e
    on d
    .deptno e.deptno
    group by d
    .deptno 

  2. #2
    Join Date
    Dec 2004
    Location
    Memphis
    Posts
    25
    Try this..

    Select d.deptno, d.dname, count(empno) from dept d left outer join emp e on d.deptno = e.deptno group by d.deptno, d.dname;
    NewKid

    A Newkid in the block

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •