SQL query [message #404082] |
Wed, 20 May 2009 05:08  |
som.sangli
Messages: 3 Registered: May 2009
|
Junior Member |
|
|
Hello friends,
I do not get following output.
Query :
List employee name, salary and his income group as 'LOW' or 'HIGH' depending upon the salary amount (If the salary is less than 4000 then he is in 'LOW' income group or else in 'HIGH' income group.)
OUTPUT should be like this:
Ename Salary LOW HIGH
-------------------------------------------------------
SCOTT 3000 LOW
KING 5000 HIGH
Please let me know if u have solution.
Thanks in advance.
----------------
Somnath
[Updated on: Wed, 20 May 2009 05:12] Report message to a moderator
|
|
|
|
|
Re: SQL query [message #404087 is a reply to message #404086] |
Wed, 20 May 2009 05:18   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
I have lot's of solutions, but I personally am not prepared to do your homework for you. Show us (by copying your formattedcode and pasting it here between [code]Your code goes here [/code] tags. I'm assuming that you are using the emp table in the scott schema. If this is not the case, then also post a test case (i.e. create table and insert statements to generate a sample of the data that you are working with)
PS please refrain from using IM speak (such as u instead of you) thanks
[Updated on: Wed, 20 May 2009 05:19] Report message to a moderator
|
|
|
|
Re: SQL query [message #404089 is a reply to message #404088] |
Wed, 20 May 2009 05:22   |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Awesome. Just do the OP's homework for him. Absolutely no point in trying to lead him to the right answer, just plonk it down in front of him just so that you can show how super and clever you are.
|
|
|
Re: SQL query [message #404093 is a reply to message #404088] |
Wed, 20 May 2009 05:29   |
som.sangli
Messages: 3 Registered: May 2009
|
Junior Member |
|
|
sr_orcl wrote on Wed, 20 May 2009 15:48 | Try This query
SELECT ename,
sal,
CASE
WHEN (sal <= 4000) THEN
'LOW'
ELSE
'HIGH'
END income_group
FROM emp
|
Hi sr_orcl,
earliar, i had tried with CASE WHEN but it had not worked.
U have given really good solution. However it doesn't give required output. I have modified query and i got required output.
I used two CASE statement for two separate columns(LOW and HIGH).
Thanks a lot.
Regards,
Somnath
|
|
|
Re: SQL query [message #404094 is a reply to message #404093] |
Wed, 20 May 2009 05:35  |
pablolee
Messages: 2882 Registered: May 2007 Location: Scotland
|
Senior Member |
|
|
Quote: | U have given really good solution. However it doesn't give required output
| That would be a bit of an oxymoronic statement surely? If it doesn't give the result, then it isn't a solution. As before, please stop using IM speak. And yet again, you refuse to post the code that you say you have written.
Good luck, I am out.
|
|
|