|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. |
|
#2
|
|||
|
|||
|
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) |
|
#3
|
|||
|
|||
|
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) |
|
#4
|
|||
|
|||
|
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 |
|
#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. |
|
#6
|
|||
|
|||
|
Quote:
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! |
![]() |
| Viewing: Dev Shed Forums > Databases > Oracle Development > Oracle Query |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|
|