How can i solve the query...?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: How can i solve the query...?

  1. #1
    Join Date
    Mar 2004
    Location
    Trichy, TN
    Posts
    5

    Angry How can i solve the query...?

    Emp Dept
    === ======
    Ename - DeptNo
    Eno - DName
    DeptNo - Location

    Count the number of employees in each department and get the department which has least number of employees


    If a table has one column named as 'X' type integer
    it contains 3,5,10,-2,15,41,2 and so on

    If we a number (i.e., that given number is in the above list) as input, get the immediate biggest number for that given one. (Query only not PL/SQL script)

  2. #2
    Join Date
    Dec 2002
    Location
    Bangalore ( India )
    Posts
    2,434
    Code:
    Select 
      Dept.Dname, A.Cnt
    From 
      ( Select Dept_No, Count(*) Cnt From Emp Group By Dept_No Order By 2) A,
      Dept
    Where
      A.Dept_No = Dept.Dept_No And
      Rownum < 2
    ;
    funky...

    "I Dont Want To Follow A Path, I would Rather Go Where There Is No Path And Leave A Trail."

    "Ego is the worst thing many have, try to overcome it & you will be the best, if not good, person on this earth"

  3. #3
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,136
    For the 2nd Qn,

    select min(x) from table_a where x > :b1;

    where b1 is your input value.

    Tamil

Posting Permissions

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



Click Here to Expand Forum to Full Width