Home » SQL & PL/SQL » SQL & PL/SQL » select a set of records
select a set of records [message #20820] Sun, 23 June 2002 23:15 Go to next message
swapna
Messages: 11
Registered: May 2002
Junior Member
I have a requirement here.
I'll explain that requrirement with a simple EMP table example.
Take a case i have lots of records in EMP TABLE with a salary column in it. If i take sum(salary) of all employee's it will be 1 Lakh.
Now my actual requirement is I want only those many records from the employee table whose sum of salaries is 50,000. Ignore all other records. I dont have any condition to get which employee records should appear in the output, but the condition is SUM(salary) is 50,000.
Hope iam clear in explaining my requirement.
Re: select a set of records [message #20829 is a reply to message #20820] Mon, 24 June 2002 06:28 Go to previous messageGo to next message
vipin
Messages: 40
Registered: May 2002
Member
Hi,
try using 'having clause' along with 'group by' which restricts the output.
Re: select a set of records [message #20873 is a reply to message #20820] Thu, 27 June 2002 01:14 Go to previous message
moloy
Messages: 8
Registered: June 2002
Junior Member
i think this query may help u and u can change to u'r
reqiurement.Just take the idea.

select EMPNO,ENAME, sum(sal) from emp group by rollup(EMPNO,ENAME) having sum(sal) <5000;
Previous Topic: Re: plsql fuction
Next Topic: pl/sql
Goto Forum:
  


Current Time: Tue Apr 23 22:33:26 CDT 2024