|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
Generate data entry and reporting .NET Web apps in minutes, straight from your database. Read our FREE whitepaper “Build Web 2.0 Applications Without Hand-Coding” Download now! |
|
#1
|
|||
|
|||
|
PL/SQL Queries
Hi
I am having a little trouble with a couple of queries. I need to display employee name and department of all employees who are lowest paid in each department, which has 2 or more employees. Salaries have to be assumed to be null. The output is to be ordered by ename within department number. This is how I have formulated the query to be: Select ename, deptno, sal count(e.empno) From emp e, dept d, salgrade s Where ((e.sal between losal and hisal) or (e.sal is null)) And e.deptno (+) = d.deptno Having count(e.empno) > 2 Order by ename, deptno But it is displaying 'no rows selected' - can you tell me where I have gone wrong? I also need to display the dpartment number and location and the number of clerks in each department within the database. This is what I have done the query as: Select loc, deptno count(job) "No of Clerks" From emp e, dept d And e.deptno(+) = d.deptno And job = Clerk Group by d.deptno, loc However, it is coming up with an error message that 'e.empno' - any ideas of how I can rectify this? Cheers Av. |
|
#2
|
|||
|
|||
|
I think you have some problems with the sql syntax.
For starters: And e.deptno(+) = d.deptno <--- not a valid sql statement perhaps you meant: And e.deptno = d.deptno ??? fv
__________________
...because that is the way we have always done it. We've been doing it like that for 80 Years! (How do we change that mindset?) |
|
#3
|
|||
|
|||
|
@fractalvibes
Dude i think you misunderstood...... the syntax is correct..... if u add (+) symbol in a query it's called outer join...... check it out again......... The use of (+) symbol is absolutely valid....... |
|
#4
|
||||
|
||||
|
Quote:
however, this is the db2 forum ![]() |
![]() |
| Viewing: Dev Shed Forums > Databases > DB2 Development > PL/SQL Queries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|