Home » SQL & PL/SQL » SQL & PL/SQL » Year to Date Amounts (Oracle 10g)
Year to Date Amounts [message #403304] Thu, 14 May 2009 12:56 Go to next message
Leonard Martin
Messages: 45
Registered: May 2002
Location: Canada
Member
Hello
I need to write a query that will accept 2 parameters

1. From Month, Year
2. To Month , Year

Using these parameters I need to display the output in the following format:

Name, Total Salary(Current Month), Total Salary(Previous Month), Total Salary (Year To Date)

Lets assume that the Table has the following 2 columns:

Name, Salary

Thanks in Advance
Leonard
Re: Year to Date Amounts [message #403305 is a reply to message #403304] Thu, 14 May 2009 13:01 Go to previous messageGo to next message
Michel Cadot
Messages: 64103
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Post a working Test case: create table and insert statements along with the result you want with these data.

Don't forget as requested in your previous topic to please read OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code (See SQL Formatter), use code tags and align the columns in result.
Use the "Preview Message" button to verify.
Also always post your Oracle version (4 decimals).

Regards
Michel
Re: Year to Date Amounts [message #403306 is a reply to message #403304] Thu, 14 May 2009 13:29 Go to previous messageGo to next message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
Without a column that holds date, you are not going to be able to do any calculations with dates.
Re: Year to Date Amounts [message #403310 is a reply to message #403306] Thu, 14 May 2009 14:33 Go to previous messageGo to next message
Leonard Martin
Messages: 45
Registered: May 2002
Location: Canada
Member
Sorry, I should have mentioned.
The table will also contain a DATE_PAID column.

Thanks
Leonard
Re: Year to Date Amounts [message #403311 is a reply to message #403304] Thu, 14 May 2009 14:49 Go to previous messageGo to next message
BlackSwan
Messages: 25033
Registered: January 2009
Location: SoCal
Senior Member
>I should have
You should have read & followed Michel's post instead of offering excuses.


Re: Year to Date Amounts [message #403316 is a reply to message #403310] Thu, 14 May 2009 15:07 Go to previous message
joy_division
Messages: 4640
Registered: February 2005
Location: East Coast USA
Senior Member
Here are some hints. Look at the results of these two queries.
select trunc(sysdate,'Month') from dual;
select trunc(sysdate,'YYYY') from dual;

Previous Topic: Database size
Next Topic: need help getting primary key from table
Goto Forum:
  


Current Time: Sat Dec 03 10:11:33 CST 2016

Total time taken to generate the page: 0.11251 seconds