Oracle Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesOracle 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
  #1  
Old August 24th, 2004, 05:42 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
Oracle Query

Hi

Im new to Oracle and need some help with some queries

I need to write a query to show the department number, location and number of clerks - how would I do this?

Also I need to update the commission of salesmen by 1.5% of the income they have from all the sales they are connected with.

Is there anyway of doing these queries and getting the correct data to be displayed.

Reply With Quote
  #2  
Old August 24th, 2004, 07:44 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
You did not provide the structure of table but i assumed that you are talking about the table defined in user scott.
I need to write a query to show the department number, location and number of clerks??

Query:
------
SELECT d.deptno.d.dname,d.loc
FROM emp e, dept d
WHERE d.deptno = e.deptno
AND e.job = 'CLERK'
/

update the commission of salesmen by 1.5% of the income they have from all the sales they are connected with.

Query:
------
UPDATE employee X
SET total_comm = (SELECT SUM(NVL(comm,0))
FROM employee Y
WHERE Y.empno = X.empno
GROUP BY empno)

Reply With Quote
  #3  
Old August 24th, 2004, 07:51 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
Sorry see the query again

to update the commission of salesmen by 1.5% of the income they have from all the sales they are connected with.


Query:
------
UPDATE emp X
SET comm = (SELECT SUM(NVL(comm,0))*1.59
FROM emp Y
WHERE Y.empno = X.empno
GROUP BY Y.empno)

Reply With Quote
  #4  
Old August 24th, 2004, 08:32 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
Hi thanks a lot for that!

Could you just help me with a few more

I need to display employee name and department number for all employees except those who are lowest paid and that department has 2 or more employees. Salaries are assumed to be null and it to be ordered by ename within deptno.

And the other one is I need to determine the customer identifier and customer name of the two customers who have generated the most sales.

Any ideas - and yeas it is scott that I am trying to use!!

Thanks

Reply With Quote
  #5  
Old August 24th, 2004, 09:53 AM
shafique shafique is offline
Senior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Canada
Posts: 305 shafique User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 20 sec
Reputation Power: 5
to display employee name and department number for all employees except those who are lowest paid and that department has 2 or more employees.

Query:
------
SELECT e.ename, e.deptno
FROM emp e, grade g, (SELECT deptno, count(*) total
FROM emp
GROUP BY deptno) d
WHERE e.sal between g.lowsal and g.highsal
AND g.lowsal = (SELECT min(lowsal) FROM grade)
AND d.total<2
AND e.deptno = d.deptno
/

And the other one is I need to determine the customer identifier and customer name of the two customers who have generated the most sales.

SELECT custid, custname, sum(amount)
FROM sales
WHERE rownum <=2
GROUP BY custid, custname
/

would you like to tell me which tables are you using because I have some other tables and schema object in user scott and tables name are similar to each other.

Reply With Quote
  #6  
Old August 24th, 2004, 11:39 AM
smiler1 smiler1 is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2004
Posts: 22 smiler1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Quote:
Originally Posted by shafique
to display employee name and department number for all employees except those who are lowest paid and that department has 2 or more employees.

Query:
------
SELECT e.ename, e.deptno
FROM emp e, grade g, (SELECT deptno, count(*) total
FROM emp
GROUP BY deptno) d
WHERE e.sal between g.lowsal and g.highsal
AND g.lowsal = (SELECT min(lowsal) FROM grade)
AND d.total<2
AND e.deptno = d.deptno
/

And the other one is I need to determine the customer identifier and customer name of the two customers who have generated the most sales.

SELECT custid, custname, sum(amount)
FROM sales
WHERE rownum <=2
GROUP BY custid, custname
/

would you like to tell me which tables are you using because I have some other tables and schema object in user scott and tables name are similar to each other.


Hi Thanks for your help.

Yeah the tables I have are Emp, Dept, Bonus, Salgrade, Customer, Ord, Item, Product, Price.

If you would like me to tell which schema I have within these tables I can tell you.

Thanks again for all your help, its much appreciated!

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesOracle Development > Oracle Query


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

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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





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