Article:
  SQL Subqueries
Subject:   help
Date:   2005-09-13 21:47:18
From:   sumeet_
i want to select all columns from a table for the minimum of two columns. the table has few records with both minimums coming together.so i want these rows.


i tried e.g.


select distinct * from emp where sal=(select min( e.sal) from emp e where e.deptno <= (select min(t.deptno) from emp t));



i also tried


select * from emp where sal=(select min( e.sal) from emp e where 1=(select count ( di
stinct empno) from emp t where e.deptno <=t.deptno group by e.sal));



Full Threads Newest First

Showing messages 1 through 2 of 2.

  • help
    2005-12-22 13:12:18  dazednconfused [View]

    Try looking up Having clause. It should work then.
    • help
      2007-07-05 15:25:49  Poon [View]

      You can try :
      select * from employee where salary=(select min(salary) from employee) and
      department_id=(select min(department_id) from Department);