Get the date of the previous year
Hi allHow can I recover date from the previous year, based on today's date, if I have a data type 'date '.
Marwim wrote:
Hello BluShadow,You should know better ;-)
select date '2004-02-29' - interval '1' year from dual; ORA-01839: date not valid for month specified
Well, today he works.
Concerning
MarcusEdited by: Marwim the 13.10.2011 17:06
Ah, good point. Really, it's oracle who should know better. It should do the same thing as:
select add_months(date '2004-02-29',-12) from dual;
Tags: Database
Similar Questions
-
Hi all
I created a form with 5 blocks (namely ENQACMHDR, ENQACMDTL, ENQACEHDR, ENQACEDTL, ENQACSPEC), where I have 8 push buttons (namely ENTER_QUERY, EXEC_QUERY, CLEAR, FIRST, NEXT, PREVIOUS, LAST, and EXIT).
This form is created just for display purposes only. So after that I ran, all blocks have been blocked against insert and update.
I have question on 2 fields 'ENQNO' and "RATNG" (both belong to the ENQACMDTL block).
When I click on "EXEC_QUERY" directly, all data for all years fills.
But the user wanted the data to be populated only this year and the previous year.
Yes, on ' Clause WHERE' of the property_palette of the 'ENQACMDTL' block , I put in the following condition:
SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYY') OR SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (SYSDATE, 'YYYY')
PROPERTY PALETTE (ENQACMDTL block) WHERE Clause SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (ADD_MONTHS (SYSDATE,-12), 'YYYY') OR SUBSTR (ENQACMDTL. ENQNO, 1, 4) = TO_CHAR (SYSDATE, 'YYYY') Data only this year and the year before are now filled. Its ok with the field of "ENQNO".
The problem is when I have queries on the field "RATNG. 'RATNG' is a Text_item with number of displayed items = 5. (5 lines)
Here are the 2 columns in a Table (name = ENQACMDTL) in the database.
ENQNO RATNG 2013900054 500KC2 2013900047 800KC4 2013520018 750KC6 ...... ......... 2012900037 1000KC2 2012520109 500KC2 2012140019 750KC6 ........ .......... 2011540036 500KC2 2011100030 1000KC2 ......... ......... ...... ........... 2006100007 90KD8 2006750014 750KC6 2006900072 500KC2 The first 4 issues of "ENQNO" represents the year. There is more than a lakhs of records.
So, when I have queries on the field "RATNG."
Example: for RATNG = 500KC2;
I click on ENTER_QUERY, the field of "RATNG", I put in the 500KC2 of the value and click on EXEC_QUERY; Details regarding the 500KC2 is displayed as well as all the other junk RATNG as 750KC6, 1000KC2 (which belongs to the ENQNO of the current year and previous year) also gets displayed.
I want details of only RATNG (500KC2) to display, but only for the current year and the previous year, it is 2013900054, 2012520109 (ENQNO).
Other than 500KC2 RATNG, no other RATNG must be displayed.
500KC2 = RATNG is also present for ENQNO = 2011540036, 2006900072. But I don't want them to view.
I want only the data or details of the current year and the previous year to be filled or displayed for the given RATNG.
Can you help me or tell me what I do for this?
Hope I'm clear with my question!
If my question is not clear, let me know please.
Thank you.
Oracle9i Enterprise Edition Release 9.2.0.1.0 - Production
Oracle forms 6i.
1. check null values in the enqacmdtl.enqno, if so treat them properly.
2. check the result of select to_char (add_months (sysdate,-12), 'YYYY') prev_year curr_year of double to_char(sysdate,'YYYY')
3. change the place where clause "year" in the value of numAriques.
where to_number (substr (enqacmdtl.enqno, 1, 4)) > = to_number (to_char (add_months (sysdate,-12), 'YYYY'))
Then let me know the result.
-
How to get the fiscal year previous last day?
I created a line of dashboard with a column of the calendar date. Duty of the user is to display the previous year sales last day i.e. 31 March of the year for the date played.
How is it achievable? Please answer anyone who implemented logic.
Fiscal year starts from 01 Apr.
Dear Philippe,
Sometimes we are not able to provide a complete solution for you, but we can guide you because we are a busy lot in our own tasks... here, I worked a formula for you...
-case when Date ' @{PV} {2014-04-04}<=TIMESTAMPADD(SQL_TSI_MONTH, 3,timestampadd(="" sql_tsi_day="" ,="" extract(="" day_of_year="" from="" pv)="" *="" -(1)="" ,="" pv))="">=TIMESTAMPADD(SQL_TSI_MONTH,>
TIMESTAMPADD (SQL_TSI_MONTH-9, TIMESTAMPADD (SQL_TSI_DAY, EXTRACT (DAY_OF_YEAR pv) *-(1), pv)) else
TIMESTAMPADD (SQL_TSI_MONTH, 3, TIMESTAMPADD (SQL_TSI_DAY, EXTRACT (DAY_OF_YEAR pv) *-(1), pv)) end
I could not test this by obiee. But have a try and let us know if no door.
Thank you
AJ
-
SQL to get % increase in the amount of the previous year
Version 11g
Hello
I have a requirement where I need to calculate the percent increase of wages and costs compared to the previous year,
If the output should be something like
The inclusion of scripts areYear Salary %increase Rent %Increase 2012 1000 1000% 100 1000% 2011 100 100% 10 100%(depending on last year value) 2010 . . . . . .
Any suggestions on how we can calculate the increase in % at run time?create table sal (exp_type varchar2(100), exp_date date, exp_amt number); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-JUN-11','DD-MON-RR'),685); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-JUN-11','DD-MON-RR'),84.89); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-JUL-11','DD-MON-RR'),685); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-JUL-11','DD-MON-RR'),84.89); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-AUG-11','DD-MON-RR'),687); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-AUG-11','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-SEP-11','DD-MON-RR'),687); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-SEP-11','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-OCT-11','DD-MON-RR'),750); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-OCT-11','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-NOV-11','DD-MON-RR'),750); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-NOV-11','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-DEC-11','DD-MON-RR'),755); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-DEC-11','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-JAN-12','DD-MON-RR'),755); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-JAN-12','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-FEB-12','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-FEB-12','DD-MON-RR'),750); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-MAR-12','DD-MON-RR'),766); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-MAR-12','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-JUN-12','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-JUN-12','DD-MON-RR'),740); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('02-JUL-12','DD-MON-RR'),735); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('02-JUL-12','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-AUG-12','DD-MON-RR'),739); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-AUG-12','DD-MON-RR'),93.4); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('02-SEP-12','DD-MON-RR'),740); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('02-SEP-12','DD-MON-RR'),93.4); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-APR-12','DD-MON-RR'),570); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-APR-12','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-MAY-12','DD-MON-RR'),740); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-MAY-12','DD-MON-RR'),89.04); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-NOV-12','DD-MON-RR'),845); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-NOV-12','DD-MON-RR'),93.4); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-OCT-12','DD-MON-RR'),900); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-OCT-12','DD-MON-RR'),93.4); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-FEB-10','DD-MON-RR'),508); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-FEB-10','DD-MON-RR'),84.89); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('03-MAR-10','DD-MON-RR'),84.89); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('03-MAR-10','DD-MON-RR'),500); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-APR-10','DD-MON-RR'),509); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('04-APR-10','DD-MON-RR'),84.89); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Rent',to_date('01-MAY-10','DD-MON-RR'),84.89); Insert into SAL (EXP_TYPE,EXP_DATE,"EXP_AMT") values ('Salary',to_date('01-MAY-10','DD-MON-RR'),514.46);
Thank you
RyanHello
ryansun wrote:
Thank you Al, Frank!I am struggling with the math a bit part. Or maybe % increase is not the correct term. So what I want is the increase in rent and wages in terms of % over the previous year. Thus, for example the output below.
The salary in 2012 is 8280
The salary in 2011 is 4999so 8280-4999 = 3281
3281 is 65.6% of 4999.
The increase last year was 65.6% compared to the last years value while the output of two sqls 165,6%
Right, Al and I assumed you wanted the percent of last year, not the percentages of increase... Subtract 100 if you want the percentage increase.
-
Sales of the previous year with the guest of the current year
Hello
I have the year and sales in the criteria and my year is receiving messages. When I select the current year, my report must return data for the current year and previous year and if I select the previous year in the command prompt report should indicate the previous year and before yr previous data. Could you help us meet this goal.
Thanks for your help. I was able to do with the variable of presentation... My intention was not to change anything in the RPD. My time dimension is something not clear.
I just used below the formula to this YEAR being my PV.
FILTER ("Operation". "Unit price" USING ((cast ("Temps de la Transaction".))) " ((Year of operation"AS INTEGER)) = @{YEAR} {2014}))
FILTER ("Operation". "Unit price" USING ((cast ("Temps de la Transaction".))) " ((Year of operation"AS INTEGER)) = @{YEAR} - 1))
-
Hello peers - how can we calculate CDA days in the current year, CDA days in the previous year using SQL Timestampadd/Timestampdiff works and store them as variables to repository? Appreciate any inputs.
Thank you.
Regarding the answer to your other question (How to use the functions Timestampadd/Timestampdiff in the repository Variables) you don't need to use timestampadd / timestampdiff for a block init but real SQL, to verify the features in charge of your database.
PS: Days CDA? If you just want to know the day number based on the year?
-
Hi all
We have an obligation to state the previous year, current year and values of the year next as a LOV in the ADF page.
This is the query that retrieves the previous year, current year and next year. But the result of this query displays values in 3 columns:
Select (Extract(year from sysdate)-1), extract (year sysdate), (extract (year sysdate) + 1) twice;
Output:
2012 2013 2014
But I want to display them in a single with 3 rows as column:
2012
2013
2014
Please your ideas.
or in the same way
SELECT EXTRACT (YEAR FROM ADD_MONTHS (SYSDATE, 12 *(LEVEL-2)))
OF the double
connect by level<>
-
How can I get the previous version of Muse?
HTML & Javascript in an HTML embeded object does not work properly since I downloaded the latest update (November 2013). How/where can I get the previous version of Muse?
I understand the problem. My code was beautiful, but a feature in 'on' by default in the update of November 2013 Muse has created the problem.
The thumbnails on my homepage are PNG files. They are there by registering directly (via the button placed under the file menu). However, on my subpages, the thumbnails are referenced via Javascript in an HTML object. Like the placement of the tiles according to the results of the homepage of them being available in the generated Muse 'image' file when the site is exported, I can refer to them later Javascript in an HTML object in the pages following (I do this to show some random images). However, the files that I placed on my homepage are PNG and Muse was exporting as JPG because of a feature (in file / properties of the Site) is checked by default in Version 7. The feature is "opaque PNG convert to JPEG". Once I unchecked that defining and re-exported my site referenced by my Javascript PNG thumbnails appear on the subpages.
P.S. A couple of hours on the merry Road round to find the question - Ouch!
-
Facing the question in calc script while trip data for the current year to the previous year
Hi all
Need your serious help in my calc script.
I am writing a calc script to transfer data from order book of FY15 Q1 to Q4 FY14 here is the problem in my script. If spin this script to copy the same year, it works fine but when trying to load between two different years, it does not work. could someone help me please. where miss me the logic. Thanks for the help in advance.
Here's the script:
ESS_LOCALE English_UnitedStates.Latin1@Binary
SET AGGMISSG
DIFFICULTY (@List ("real GL", "Real ML", "ACT", & ActualLoadYrBklg))
() "Dec / (Inc.) in suffering.
IF (@Ismbr ("Q4"))
"Dec / (Inc.) in suffering (Non - di) =.
-1 * (("Q1"-> "starting Backlog",-1,@Relative("Years",0)) @Prior - ' count backward (Non - di) ");
"DENTE change overdue =.
-1 * (@Prior ("Q1"-> "Cost",-1, @Relative("Years",0))-"Cost of rear" rear);
Else if (@IsMbr ("Q1": "Q3"))
"Dec / (Inc) order book ' =-1 * (@Prior ('Rear start',-1, @Relative("YearTotal",0))-" starting back (Non - di) "");
'Change of GEAR wheels in suffering' =-1 * (@Prior ("backward Cost",-1,@Relative("YearTotal",0)) - "money back");
endif ;)
endfix
SM.
My first question is what is the order of members in your dimension years and quarter the level low your dimension of periods? Secondly, what dimensions are rare and dense (can you tell me which members in the calc are in dense and sparse dimensions)
Third, you cite the specific years FY15 and FY14, I suppose that & ActYearBklg is FY15 assuming this is correct, I would add a substitution variable for & PriorYrBklg with FY14 inside (if I'm back, and then modify the variables) for clarity, I'm going to hardcode the values in the Calc. It also assumes years is sparse
You can try this
FIX ("GL 'real 'real ML", "ACT", "FY15") / * you need not @list * /.
() "Dec / (Inc.) in suffering.
IF (@Ismbr ("Q4"))
"Dec / (Inc.) in suffering (Non - di)"-> "FY14 =.
-1 * ("Q1'-> 'backlog begins' - 'Start rear (Non - di)'->"FY14");
"DENTE change orders"-> "FY14 =.
-1 * ("Q1"-> "Of back - cost"Back cost"-> FY14");
Else if (@IsMbr ("Q1": "Q3"))
("Dec / (Inc) order book"-> "FY14' =-1 * beginning backlog->"FY14'-'Begins the backlog (Non - di)');
'Change of CMV in the order book "->" FY14' =-1 * ('Back cost'-'Back cost'-> "FY14");
endif ;)
endfix
The years may be replaced by the subvars
-
How to get the previous month and year accordingly
Hi friends,
I wanted to select the month as a number like 4 and the new year 2011
but I want to choose the previous month from sysdate
as if the sysdate is June 10, 2011
It should give me 5 months and
in the year, it should give as 2011
If the sysdate is January 1, 2012
the month should be like 12 and year should be in 2011
Thank youHello
776317 wrote:
Thank you very much I just the 0 being the prefix... can you pls how to avoid that too well plsTO_CHAR ( ADD_MONTHS (SYSDATE, -1) , 'FMmm yyyy' )
For more information on the FM, wee manual SQL language modifier works:
http://download.Oracle.com/docs/CD/B28359_01/server.111/b28286/sql_elements004.htm#sthref456 -
the higher the code for the date, I need the previous day. How to write the query to do thisto_char(AHB.trh_BICARA,'dd') dat1, to_char(AHB.trh_BICARA,'yyyy') year1, DECODE (TO_CHAR (AHB.trh_BICARA, 'DY'), 'SUN','AHAD', 'MON','ISNIN', 'TUE','SELASA', 'WED','RABU', 'THU','KHAMIS', 'FRI','JUMAAT', 'SAT','SABTU' ) day, DECODE (TO_CHAR (AHB.trh_BICARA, 'MM'), '01', 'JANUARI', '02', 'FEBRUARI', '03', 'MAC', '04', 'APRIL', '05', 'MEI', '06', 'JUN', '07', 'JULAI', '08', 'OGOS', '09', 'SEPTEMBER', '10', 'OKTOBER', '11', 'NOVEMBER', '12', 'DISEMBER' ) month1
Hello
I'm not sure that understand the question.
If AHB.trh_BICARA is a DATE, then
AHB.trh_BICARA - 1
is the DATE exactly 24 hours earlier.
So, ifDECODE ( TO_CHAR (AHB.trh_BICARA, 'DY'), 'SUN', 'AHAD', 'MON', 'ISNIN', 'TUE', 'SELASA', 'WED', 'RABU', 'THU', 'KHAMIS', 'FRI', 'JUMAAT', 'SAT', 'SABTU' )
Returns "AHAD", then
DECODE ( TO_CHAR (AHB.trh_BICARA - 1, 'DY'), 'SUN', 'AHAD', 'MON', 'ISNIN', 'TUE', 'SELASA', 'WED', 'RABU', 'THU', 'KHAMIS', 'FRI', 'JUMAAT', 'SAT', 'SABTU' )
will return 'DUBOIS '.
-
Hi Experts,
My query below is beginning of quarter end and previous quarter start and end dates according to the calendar year... Now, I have to get the values accordingly exercise...
Thanks in advance for the support...SELECT MIN (t)"CURNT_QTR_ST_DT", MAX (LAST_DAY (t))"CURNT_QTR_END_DT", ADD_MONTHS(MIN (t),-3)"PREV_QTR_ST_DT", ADD_MONTHS(MAX (LAST_DAY (t)),-3) "PREV_QTR_END_DT" INTO V_CURRQTD_STRT ,V_CURRQTD_END,V_PRVQTD_STRT, V_PRVQTD_END FROM (SELECT ADD_MONTHS (TRUNC(TO_DATE(TO_DATE(V_RPRT_DATE)), 'YYYY'), LEVEL - 1) t, TO_CHAR (ADD_MONTHS (TRUNC(TO_DATE(TO_DATE(V_RPRT_DATE)), 'YYYY'), LEVEL - 1), 'Q')QTD FROM DUAL CONNECT BY LEVEL <= 12) A WHERE A.QTD = V_QUARTER_NUMBER;
Hello
You don't need the double table much in PL/SQL.
Another thing that makes PL/SQL, SQL different programming, it's that, in SQL, you can assign an alias for a column, but you can only refer to this alias in a Super application (or in an ORDER BY clause). In PL/SQL, you can reference a variable once it is set.
In PL/SQL, once you have a DATE deadline in t, you can set the 4 variables like this:
v_currqtd_strt := TRUNC (t, 'Q'); v_currqtd_end := ADD_MONTHS (v_currqtd_start, 3) - 1; v_prvqtd_strt := ADD_MONTHS (v_currqtd_start, -3); v_prvqtd_end := v_currqtd_start - 1;
Use SELECT... IN PL/SQL when the data in a table, and you must copy these data in variables. (It seemed that you forgot the INTO clause in your last post).
However, in this case, no data in a table you need to copy, it is not necessary for a SELECT statement. -
Hi Experts,
Can someone tell me to get the previos months beginning and end date...
If m 20-dec-2012 then output should be 1 November 2012 and November 30, 2012...
Thnx in advance...977490 wrote:
Hi Experts,Can someone tell me to get the previos months beginning and end date...
If m 20-dec-2012 then output should be 1 November 2012 and November 30, 2012...
Thnx in advance...
Use
select trunc(trunc(sysdate,'MM')-1,'MM') "First Day of Last Month", trunc(sysdate,'MM')-1 "Last Day of Last Month" from dual
20-dec-2012
Select TRUNC (trunc (to_date (20-dec-2012', 'mon-dd-yyyy'), "LUN")-1, 'MY')
"First day of the month pr."
trunc (to_date (20-dec-2012', 'mon-dd-yyyy'), "LUN")-1
"Last day of the previous month.
of the doublePublished by: Rahul India on January 24, 2013 14:37
-
Find the stock quantity of the previous year with another way...
Hello
I have a table with the following structure:create table stock_qties_items
and some data...
(subinv varchar2(10),item_code varchar2(10),period_name varchar2(5), qty_a number(5,2), qty_b number(5,2));
alter table stock_qties_items
add constraint stock_qties_items_pk primary key(subinv,item_code,period_name);insert into stock_qties_items
The goal is to find the stock for the current year and previous year. I have accomplished with the following...
values('01','410010010','01-08',10.50,0);
insert into stock_qties_items
values('01','410010010','02-08',19.30,10.35);
insert into stock_qties_items
values('01','410010010','03-08',3,0);
insert into stock_qties_items
values('02','410010010','03-08',8.54,1.90);
insert into stock_qties_items
values('03','410010010','03-08',120.45,1.25);
insert into stock_qties_items
values('03','410010010','04-08',502.10,6.50);
insert into stock_qties_items
values('03','410010010','05-08',5.05,6.20);
insert into stock_qties_items
values('03','410010010','08-08',19.35,65.90);
insert into stock_qties_items
values('02','410010010','10-08',40.85,5.20);
insert into stock_qties_items
values('03','410010010','12-08',75.20,90.15);
insert into stock_qties_items
values('02','410010020','12-08',60.55,0.85);
insert into stock_qties_items
values('01','410010020','07-08',100.90,10.05);
insert into stock_qties_items
values('01','410010010','01-09',8.95,0.05);
insert into stock_qties_items
values('02','410010010','01-09',88.95,100.05);
insert into stock_qties_items
values('03','410010020','01-09',91.05,0.05);
insert into stock_qties_items
values('04','410010020','01-09',11.75,10.05);
insert into stock_qties_items
values('04','410010010','03-09',1.75,110.40);
insert into stock_qties_items
values('04','410010010','05-09',0.75,10.40);
insert into stock_qties_items
values('04','410010025','03-09',1.75,90.00);
insert into stock_qties_items
values('04','410010025','07-09',51.75,190.00);
insert into stock_qties_items
values('04','410010010','09-09',62.15,10.05);
insert into stock_qties_items
values('04','410010010','10-09',39.15,0);select period_year,
which generates the following output...
item_code,
sqi1 stock_prev_year,
sum(stock_curr_year) stock_curr_year
from
(
select to_char(to_date(substr(period_name,4,2),'RRRR'),'RRRR') period_year,
item_code,
(select sum(qty_a+qty_b)
from stock_qties_items sq
where sq.item_code=sqi.item_code
and to_char(to_date(to_number(substr(sqi.period_name,4,2)-1),'RRRR'),'RRRR')=
to_char(to_date(substr(sq.period_name,4,2),'RRRR'),'RRRR')
) sqi1,
qty_a+qty_b stock_curr_year
from stock_qties_items sqi
)
group by period_year,
item_code,
sqi1PERIOD_YEAR ITEM_CODE STOCK_PREV_YEAR STOCK_CURR_YEAR
Y at - it another way to achieve the same result, given that this table has a few million records and in this request a few other tables parameter should be added...?
----------- ---------- --------------- ---------------
2008 410010020 172,35
2009 410010010 991,79 432,65
2008 410010010 991,79
2009 410010025 333,5
2009 410010020 172,35 112,9
Note: I use Db 10 g v.2
Thank you
SIMUsing the LAG function:
SQL> with t as ( 2 select to_char(to_date(substr(period_name,4,2),'RRRR'),'RRRR') period_year, 3 ITEM_CODE, sum(qty_a+qty_b) STOCK 4 from stock_qties_items 5 group by to_char(to_date(substr(period_name,4,2),'RRRR'),'RRRR'), ITEM_CODE 6 ) 7 select period_year, ITEM_CODE, 8 lag(stock) over (partition by ITEM_CODE order by period_year) stock_prev_year, 9 stock stock_curr_year 10 from t 11 order by item_code, period_year; PERI ITEM_CODE STOCK_PREV_YEAR STOCK_CURR_YEAR ---- ---------- --------------- --------------- 2008 410010010 991,79 2009 410010010 991,79 432,65 2008 410010020 172,35 2009 410010020 172,35 112,9 2009 410010025 333,5
Max
[My Italian oracle Blog | http://oracleitalia.wordpress.com/2010/01/30/compilazione-condizionale-in-plsql/] -
I accidentally saved a document in another document; can I get the previous document
I typed a document, saved and then deleted the parties out of this page in order to use the format for my next assignment. Saved from the previous assignment. Is it possible to recover the previous assignment?
I typed a document, saved and then deleted the parties out of this page in order to use the format for my next assignment. Saved from the previous assignment. Is it possible to recover the previous assignment?
Hello
Go to the folder where the previous document has been saved.
Right-click on this file and select Properties / Previous Versions tab.
Wait for the list to be completed.
Select a Version prior to an earlier date when you made the changes.
Click the copy button.
Select the desktop as the location to place the copy and click the copy button again.
Once you have finished, click OK.
Go to your desktop, open the copied folder. You should see the previous version of this document.
Concerning
Maybe you are looking for
-
Unable to access registry editor
original title: Refister Editor I don't find the registry editor in my assesories. Where can I find this file > Thank you Molstar
-
We made a reservation on the online system, we are trying to develop a version of blackberry, but we are not able to properly view the css. In the Simulator browser, everything works normally. Please take a look at www.grottagiustispa.com: when you t
-
Palm TX + Vista Hot Sync problem
I downloaded the Desktop 6.2.2 version and installed Docs to go worm. 10.002 on my Vista laptop. When I try to HotSync, the Palm stops and restarts without HotSync. Can't HotSync with my old XP machine and the worm office. 4 1-2.
-
I have a laptop Compaq Presario CQ56. After Windows 7 run for 3-5 minutes, the computer crashes. What should I do now. I would like to fix it myself if I can. I ran the Hp system tune up, here is the results... Help, please! MEM test: passed SMART te
-
publication on YouTube problems
When I try to post it on youtube, (captivate) - captivate pocesses the project, but then, I get a window "Please wait...". "that doesn't go away! someone knows why?