Home » SQL & PL/SQL » SQL & PL/SQL » Basic homework question (merged 3 similar questions)
Basic homework question (merged 3 similar questions) [message #234247] Mon, 30 April 2007 10:28 Go to next message
Maple50175
Messages: 16
Registered: April 2007
Location: MA
Junior Member

What is the SQL to get this:


I need a query to display the name, department number, and department name for all employees.

ENAME DEPTNO DNAME
KING 10 ACCOUNTING
BLAKE 30 SALES
CLARK 10 ACCOUNTING
JONES 20 RESEARCH
MARTIN 30 SALES
ALLEN 30 SALES
TURNER 30 SALES
JAMES 30 SALES
WARD 30 SALES
FORD 20 RESEARCH
SMITH 20 RESEARCH
SCOTT 20 RESEARCH
ADAMS 20 RESEARCH
MILLER 10 ACCOUNTING

14 rows selected.
Re: query to display the name, dept number, and dname [message #234248 is a reply to message #234247] Mon, 30 April 2007 10:30 Go to previous messageGo to next message
skooman
Messages: 912
Registered: March 2005
Location: Netherlands
Senior Member
What did you try so far and where did you get stuck?
finding employees to work in same dept. w/ colums [message #234249 is a reply to message #234247] Mon, 30 April 2007 10:32 Go to previous messageGo to next message
Maple50175
Messages: 16
Registered: April 2007
Location: MA
Junior Member

I need to display the employee name, department number, and all the employees that work in the same department as a given employee. And I have to give it the appropriate label.



DEPARTMENT EMPLOYEE COLLEAGUE
------------------- --------------- -----------------
10 CLARK KING
10 CLARK MILLER
10 KING CLARK
10 KING MILLER
10 MILLER CLARK
10 MILLER KING
20 ADAMS FORD
20 ADAMS JONES
20 ADAMS SCOTT
20 ADAMS SMITH
20 FORD ADAMS
20 FORD JONES
20 FORD SCOTT
. . .
56 rows selected.
Query to display name and hire date after certain employee? [message #234251 is a reply to message #234247] Mon, 30 April 2007 10:37 Go to previous messageGo to next message
Maple50175
Messages: 16
Registered: April 2007
Location: MA
Junior Member

Hey guys, I need to make a query to display the name and hire date of any employee hired after employee Blake.



Needs to look like below.




ENAME HIREDATE
------------- -----------------
KING 17-NOV-81
CLARK 09-JUN-81
MARTIN 28-SEP-81
TURNER 08-SEP-81
JAMES 03-DEC-81
FORD 03-DEC-81
SCOTT 09-DEC-82
ADAMS 12-JAN-83
MILLER 23-JAN-82
9 rows selected.
Re: finding employees to work in same dept. w/ colums [message #234254 is a reply to message #234249] Mon, 30 April 2007 10:42 Go to previous messageGo to next message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
This is the second homework question you have posted. We will help you, but will not spoon feed you. Show us what you have tried and we will help. otherwise, forget it.
Re: Query to display name and hire date after certain employee? [message #234259 is a reply to message #234251] Mon, 30 April 2007 11:09 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
And your problem finding the query is?

Regards
Michel
Re: query to display the name, dept number, and dname [message #234260 is a reply to message #234247] Mon, 30 April 2007 11:11 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Hum! What about having a look at SELECT statement in documentation?
Hum! What about read the whole SQL Reference?

Regards
Michel
Re: Basic homework question (merged 3 similar questions) [message #234306 is a reply to message #234247] Mon, 30 April 2007 15:28 Go to previous messageGo to next message
Maple50175
Messages: 16
Registered: April 2007
Location: MA
Junior Member

I have read things on here, I have NOT a clue what to do.
Re: Basic homework question (merged 3 similar questions) [message #234307 is a reply to message #234247] Mon, 30 April 2007 15:32 Go to previous message
Bill B
Messages: 1482
Registered: December 2004
Senior Member
I will not write your code, but I will give some clues. Break the task down into steps. For example, in the task where you have to find all the employees in the same dept as a specific employee, break it into steps.

1) Write a query to return the dept of a specific employee.
2) Write a query to return all the employees in a specific dept.
3) Combine the two queries (hint...Sub-select).
Previous Topic: PLS-00402
Next Topic: gap analysis for 9i to 10 g migration
Goto Forum:
  


Current Time: Sat Dec 03 22:13:20 CST 2016

Total time taken to generate the page: 0.08362 seconds