Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 please solve this sql query for me.

Author  Topic 

ramkumarodc
Starting Member

5 Posts

Posted - 2010-09-16 : 04:31:49
1.Display the manager number and the salary of the lowest paid employee for that manager.
Exclude anyone whose manager is not known. Exclude any groups where the minimum
salary is $6,000 or less. Sort the output in descending order of salary.

2.Write a query to show the employee and the manager ids. The query should populate the manager id as the employee id itself if the employee doesn’t have a manager. In the result set, the Manager list should have the heading “Boss”.

R~K

R~K

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2010-09-16 : 04:40:39
Still no answer about what you have tried so far...


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-09-16 : 04:41:23
SO. Homework question.......

NO. I will not solve the sql query for you.

However, here is how you should start thinking about the problem:

1 Manager Number and salary of the lowest paid employee for that manager.

sounds like a GROUP BY with a MIN aggregate function

Exclude anyone whose manager is not known...

Sounds like a JOIN (an inner join)

.....
.....

And the rest is up to you.

You won't learn anything if you just get the answer from somewhere.

If you try something feel free to show us what you tried -- then you'll get feedback and help.

Good luck


Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

ramkumarodc
Starting Member

5 Posts

Posted - 2010-09-16 : 05:17:13
ok i will try and post the result

R~K
Go to Top of Page

ramkumarodc
Starting Member

5 Posts

Posted - 2010-09-16 : 07:52:42
can any one give me a syntax for copy a table in oracle using subqueries by renaming the column.

R~K
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2010-09-16 : 09:08:16
If you are working in ORACLE, try here: http://www.dbforums.com/oracle/

http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspx
How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

For ultra basic questions, follow these links.
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

ramkumarodc
Starting Member

5 Posts

Posted - 2010-09-23 : 05:07:46
i tried this answer....

1.Display the manager number and the salary of the lowest paid employee for that manager. Exclude anyone whose manager is not known. Exclude any groups where the minimum salary is $6,000 or less. Sort the output in descending order of salary.
Answer:
select mgr, min(sal) from emp where mgr is not null and sal>6000 order by sal desc;

2.Write a query to show the employee and the manager ids. The query should populate the manager id as the employee id itself if the employee doesn’t have a manager. In the result set, the Manager list should have the heading “Boss”.
ANS: select Empid,nvl(mgr,empid)as boss from emp;

R~K
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-09-23 : 05:11:43
Not quite.

Hint -- you need a GROUP BY and a HAVING clause to fulfil the requirement.

Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

rohitvishwakarma
Posting Yak Master

232 Posts

Posted - 2010-09-23 : 05:14:14
2.Write a query to show the employee and the manager ids. The query should populate the manager id as the employee id itself if the employee doesn’t have a manager. In the result set, the Manager list should have the heading “Boss”.


SELECT empID,CASE WHEN mgr IS NULL THEN empID
ELSE mgrID
END AS [Boss]
FROM emp_A4200
Go to Top of Page
   

- Advertisement -