Home » SQL & PL/SQL » SQL & PL/SQL » Query Help!!!!!!!!!!!!!!
Query Help!!!!!!!!!!!!!! [message #238831] Sun, 20 May 2007 06:37 Go to next message
bad_boy_killa
Messages: 2
Registered: May 2007
Junior Member
Table Name is "Employees"

description:

Employee_ID varchar2(20),
Salary number,
Salary_Month date

I want output in the following format:


Employee_ID March_Salary February_Salary January_Salary
???????? ???????? ???????? 500
???????? ???????? ???????? 500



I want all employees that have a salary=500 in the Month January
I want the salary of March as well as february to be listed for each Employee_ID.

Can anyone help? thanks
Re: Query Help!!!!!!!!!!!!!! [message #238836 is a reply to message #238831] Sun, 20 May 2007 08:02 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Read How to get a quick answer to your question: TIPS AND TRICKS and post:
- your Oracle version
- what you already did to try to solve your homework.

Regards
Michel
Re: Query Help!!!!!!!!!!!!!! [message #238915 is a reply to message #238831] Mon, 21 May 2007 00:23 Go to previous messageGo to next message
adil_akbar
Messages: 8
Registered: May 2007
Location: Pakistan
Junior Member
pls try this
Mad
select empno,
decode(to_char(hiredate,'MON'),'JAN',sal,0) "JAN",
decode(to_char(hiredate,'MON'),'FEB',sal,0) "FEB",
decode(to_char(hiredate,'MON'),'MAR',sal,0) "MAR",
decode(to_char(hiredate,'MON'),'APR',sal,0) "APR",
decode(to_char(hiredate,'MON'),'MAY',sal,0) "MAY" from
emp
> Table Name is "Employees"

Adil Akbar
Re: Query Help!!!!!!!!!!!!!! [message #238922 is a reply to message #238915] Mon, 21 May 2007 00:44 Go to previous messageGo to next message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
This does not fit what OP wants to get.

Regards
Michel
Re: Query Help!!!!!!!!!!!!!! [message #238929 is a reply to message #238922] Mon, 21 May 2007 00:58 Go to previous messageGo to next message
adil_akbar
Messages: 8
Registered: May 2007
Location: Pakistan
Junior Member
are you using oracle 9!.
and explain what you want.

Adil
Re: Query Help!!!!!!!!!!!!!! [message #242504 is a reply to message #238831] Sun, 03 June 2007 00:44 Go to previous messageGo to next message
bad_boy_killa
Messages: 2
Registered: May 2007
Junior Member
I'm using Oracle 9i

I have no proposed solution so far

I need the query in SQL*PLUS

to elaborate on my query
there are three fields
Employee_ID, Salary, Salary_MONTH

I need the output to be as following example (please ignore the dots)

Employee_ID......March_Salary.....Feb_Salary.....Jan_Salary
P75...................580.................520.................500
C45...................800.................650.................500

please note that the listed output should have a condition, which is, Jan_salary should be equal to 500
Re: Query Help!!!!!!!!!!!!!! [message #242505 is a reply to message #238831] Sun, 03 June 2007 00:54 Go to previous messageGo to next message
BlackSwan
Messages: 25050
Registered: January 2009
Location: SoCal
Senior Member
>please note that the listed output should have a condition,
which is, Jan_salary should be equal to 500
9i is a marketing term & not an actual version number. ( to 4 decimal places)
OK, so what have you tried & why are/were the results not as desired?

[Updated on: Sun, 03 June 2007 00:56] by Moderator

Report message to a moderator

Re: Query Help!!!!!!!!!!!!!! [message #242506 is a reply to message #242504] Sun, 03 June 2007 00:55 Go to previous message
Michel Cadot
Messages: 64152
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Yes we read it but you didn't read what we posted:
Quote:
Read How to get a quick answer to your question: TIPS AND TRICKS and post:
- your Oracle version
- what you already did to try to solve your homework.


I just add read and apply How to format your posts
And your Oracle version must be the 4 decimals one.

Regards
Michel
Previous Topic: PLSQL Collections
Next Topic: Rownum and Between
Goto Forum:
  


Current Time: Sat Dec 10 18:11:28 CST 2016

Total time taken to generate the page: 0.24859 seconds