DB2 Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesDB2 Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old August 24th, 2004, 06:12 AM
Amisha Amisha is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 5 Amisha User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old August 25th, 2004, 09:02 PM
fractalvibes fractalvibes is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jun 2003
Location: Waco, Texas
Posts: 632 fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level)fractalvibes User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 1 Week 14 h 11 m 13 sec
Reputation Power: 22
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?)

Reply With Quote
  #3  
Old October 18th, 2007, 11:17 PM
codename3610 codename3610 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2007
Posts: 1 codename3610 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 7 m 58 sec
Reputation Power: 0
@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.......

Reply With Quote
  #4  
Old October 19th, 2007, 07:39 AM
r937's Avatar
r937 r937 is offline
SQL Consultant
Dev Shed God 25th Plane (17000 - 17499 posts)
 
Join Date: Feb 2003
Location: Toronto Canada
Posts: 17,310 r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level)r937 User rank is Lieutenant General (80000 - 90000 Reputation Level) 
Time spent in forums: 1 Month 3 Weeks 5 Days 4 h 20 m 43 sec
Reputation Power: 888
Quote:
Originally Posted by codename3610
The use of (+) symbol is absolutely valid.......
maybe in oracle, yeah (although you should be using JOIN syntax instead)

however, this is the db2 forum

__________________
r937.com | rudy.ca

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesDB2 Development > PL/SQL Queries


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway