Need to get rolling sum year wise in a query.
Hi all,
I have a table with monthid and amt columns. values are like
200501 5
200502 6
200503 6
200601 7
200602 8
200603 9
Like this i have data for all months in year. now i need to get rolling sum year and
month wise. the output should be like
200501 5
200502 11
200503 17
200601 7
200602 15
200603 24
please help me out to write a query for this.
Thanks,
Chandu
May be you want this
dev>select deptno,ename, sal,
2 sum(sal)over(partition by deptno order by ename)as sum_on_dept
3 from emp;
DEPTNO ENAME SAL SUM_ON_DEPT
10 CLARK 2450 2450
10 KING 5000 7450
10 MI_LL_ER 1300 8750
10 T*_1NU 2000 10750
20 ADAMS 1100 1100
20 FO__RD 3000 4100
20 JONES 2975 7075
20 SCOTT 3000 10075
20 SH_*U 3200 13275
20 SMITH 800 14075
30 ALLEN 1600 1600
30 BLAKE 2850 4450
30 JAMES 950 5400
30 MARTIN 1250 6650
30 TURNER 1500 8150
30 WARD 1250 9400
30 DEEP 3000 12400
D.EV 5000 5000
Similar Messages
-
Get the sum currency wise.
hi all,
i am using report 6i.
i have written query like below in data model and data is coming correct.
SELECT
bft_company
, bft_reference
, bft_charge_code
, bft_chg_basis
, bft_quantity
, bft_currency
, bft_local_amount
, bft_mode
, bft_remarks
FROM
Bdl_Freight
WHERE bft_mode = 'C'i want sum(bft_local_amount) group by currency. page wise total and grand total, at the end of the report.
my problem is i am not able to get the pagewise sum.
i have formula like below
SELECT bft_currency, sum(bft_local_amount)
FROM Bdl_Freight
WHERE bft_company = :bft_company
AND bft_reference = :bft_reference
group by bft_currency;from the above forumula i am getting grand total, but i am not able to get the page wise column. due to lack of "reset at" property.
How can i get the pagewise total baseed on the currency.
Please help.
Thanks..Hi
In Report you can get sum values based on group values/full report.
In case if you want per page- i think you should do manually like predefined rows. But is not advisable way.
Please check below link, you may have some idea
How to display pagewise total in Oracle reports?
Edited by: AppsLearner on Aug 1, 2012 9:11 AM -
Getting employee data year wise in different coulmns
My employee table consists of employee data and hiredate.I want the output to be in the following way
total numer of employees,employees hired in 1995,1996,1997,1998 in different columns.
can anyone help me in doing this
Thanks
Kiranmayeeuser10486303 wrote:
My employee table consists of employee data and hiredate.I want the output to be in the following way
total numer of employees,employees hired in 1995,1996,1997,1998 in different columns.Like this?
SQL> select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
SQL> ed
Wrote file afiedt.buf
1 with emp1 as (select rownum rn, emp.empno
2 from emp
3 where to_number(to_char(emp.hiredate,'YYYY')) = 1980)
4 ,emp2 as (select rownum rn, emp.empno
5 from emp
6 where to_number(to_char(emp.hiredate,'YYYY')) = 1981)
7 ,emp3 as (select rownum rn, emp.empno
8 from emp
9 where to_number(to_char(emp.hiredate,'YYYY')) = 1982)
10 ,emp4 as (select rownum rn, emp.empno
11 from emp
12 where to_number(to_char(emp.hiredate,'YYYY')) = 1987)
13 --
14 select emp1.empno as "1980", emp2.empno as "1981", emp3.empno as "1982", emp4.empno as "1987"
15 from emp1 full outer join emp2 on (emp1.rn = emp2.rn)
16 full outer join emp3 on (COALESCE(emp1.rn, emp2.rn) = emp3.rn)
17* full outer join emp4 on (COALESCE(emp1.rn, emp2.rn, emp3.rn) = emp4.rn)
SQL> /
1980 1981 1982 1987
7369 7499 7934 7788
7521 7876
7698
7844
7566
7902
7782
7839
7654
7900
10 rows selected.
SQL> -
How to display values year wise in a request
Hi All,
My requirement is I have 3 years of data. I need to display that data year-wise in different tables at a time i.e., suppose if i have 2010,2011,2012 data then i need to display 2010 data in one table ,2011 data in next table and 2012 data in another table in same request. At a time i should get all three years of data but in different tables.
Here table in the sense data should be separated year_wise.
How can I achieve this?
Thanks in Advance,
Regards,
SindhuHi,
It is good know you got your requirement.
Pivot table is on of the specialized view we are using to create the report. The options available in the view is same like Microsoft Excel Pivot table view.
Pivot table optioins:
Page: It is like prompt in the view itselft. If we are adding column in the page it will show all the values of that column for e.g if you are adding year column into that page tab it will show the values of the year, so we can select any particular year and can filter the report in the view itself.
Section: It will separate the report into different section by the column value which we are having in section tab.
Measures: It is the special place for adding number columns (e.g amount, employee count, quantity,revenue and etc, like that ) basically called measures in the fact table. The column dragged into the measures have special aggregation rules such as sum, min, max, avg,count and etc
excluded: if want to add any column in the saved request but donot want to display, you can drag that column into excluded tab.
Rows: These option will display the report by value of the column wise.
Columns: It will separate the measure value by the column what we are having in this tab. (for e.g if we are putting year in column tab the column 'Revenue' in the measure table will be separated by year wise.
Please mark the answer if it helpful. -
Hi i am getting data for month wise..
month wise diffrent data is coming ...
i want to sum year wise total based on month wise total..
how can i do this...As a sample code...i given here..
give your code too..
data: yr(4) type c,
sum(10) type p decimals 2.
sum = 0.
sort itab by mdate.
loop at itab into wa.
sum = sum + amount.
at end of mdate+0(4).
write:/ sum.
sum = 0.
end at.
endloop.
Message was edited by:
Ramu -
How to get current fiscal year.
Hi Experts,
I am working on Asset Management.I need to get current fiscal year.
I have to enter fiscal year on selections screen which i have to validate that it should not be greater than current fiscal year.
For above i have used following code snippet but i have hard coded variant as 'MK'.
To get variant i was using function '/IBS/RB_FI_GET_FISCAL_YEAR_VAR' but in my selection screen we have to enter multiple company codes. if i will keep this function inside loop then it may give multiple variants.
How to resolve this ?
DATA : l_year(4) type c,
l_date TYPE sy-datum.
CALL FUNCTION '/IBS/RB_FI_GET_FISCAL_YEAR_VAR'
EXPORTING
i_company_code =
IMPORTING
E_FISCAL_YEAR_VARIANT =
EXCEPTIONS
COMPANY_CODE_NOT_FOUND = 1
OTHERS = 2.
l_date = sy-datum - 700.
l_date = l_date + 1.
IF sy-subrc EQ 0.
CALL FUNCTION 'GM_GET_FISCAL_YEAR'
EXPORTING
I_DATE = l_date
i_fyv = 'MK'
IMPORTING
E_FY = l_year
EXCEPTIONS
FISCAL_YEAR_DOES_NOT_EXIST = 1
NOT_DEFINED_FOR_DATE = 2
OTHERS = 3.
IF sy-subrc EQ 0.
IF s_gjahr-low GT l_year.
PRINT Error Message "Entered fiscal year should not be greater than current fiscal year".
ENDIF.
ENDIF.make it simpler by using - DATE_TO_PERIOD_CONVERT
CALL FUNCTION 'DATE_TO_PERIOD_CONVERT'
EXPORTING
I_DATE = SY-DATUM
I_PERIV = L_VARI "Fiscal year Variant - refer to tab T009B
IMPORTING
E_BUPER = L_BUPER " Fiscal Period
E_GJAHR = L_GJAHR " Fiscal year
EXCEPTIONS
INPUT_FALSE = 1
T009_NOTFOUND = 2
T009B_NOTFOUND = 3
OTHERS = 4
Hope this will solve ur problem. -
hi, i am using oracle 10g database..
how to get the sum of column in union query ?
select * from (select 100 records from dual), (select 50 available from dual)
union
select * from (select 200 records from dual), (select 150 available from dual)
display should be like
records available
100 50
200 150
total 300 200thanks ...Peter vd Zwan wrote:
try this:Grouping by records will not produce correct results:
SQL> with a as
2 (
3 select * from (select 100 records from dual), (select 50 available from dual)
4 union
5 select * from (select 100 records from dual), (select 100 available from dual)
6 union
7 select * from (select 200 records from dual), (select 150 available from dual)
8 )
9 select
10 case when grouping(records) = 0 then null else 'total' end tot
11 ,sum(records) records
12 ,sum(available) available
13 from
14 a
15 group by
16 rollup (records)
17 ;
TOT RECORDS AVAILABLE
200 150
200 150
total 400 300
SQL> select case grouping(rownum)
2 when 1 then 'Total'
3 end display,
4 sum(records) records,
5 sum(available) available
6 from (
7 select * from (select 100 records from dual), (select 50 available from dual)
8 union
9 select * from (select 100 records from dual), (select 100 available from dual)
10 union
11 select * from (select 200 records from dual), (select 150 available from dual)
12 )
13 group by rollup(rownum)
14 /
DISPL RECORDS AVAILABLE
100 50
100 100
200 150
Total 400 300
SQL> SY. -
Need information in Year wise report
Dear All,
I am doing year wise report, in that i got total quantity for every month.
But my problem is if there is no transaction in that month i didn't get for that month, i need that month with total quantity is 0.
Please help to solve this issue.
thanks & Regards
AdinaTry this..
SELECT sum(po.No_POS) over(order by mths.dt) Quantity ,
to_char(trunc(mths.dt,'MM') , 'MON-YYYY') "Month"
from
(select count(poh.segment1) No_POS
, to_char(trunc(poh.approved_date,'MM') , 'MM-YYYY') Month_PO
from po_headers_all poh
where poh.type_lookup_code='BLANKET'
and poh.approved_flag='Y'
and poh.approved_date>=nvl(:P_FROM_DATE,poh.approved_date)
and poh.approved_date<=nvl(:P_TO_DATE,poh.approved_date)
group by trunc(poh.approved_date,'MM'))po,
(SELECT add_months('01-DEC-2005', lvl) dt
FROM (select level lvl
from dual
connect by level < 1000)) mths
WHERE to_char(trunc(mths.dt,'MM') , 'MM-YYYY')= po.Month_PO(+)
and mths.dt between :P_FROM_DATE and :P_TO_DATE
order by mths.dtMessage was edited by:
jeneesh
Tested Like..
SQL> select * from po_headers_all;
SEGMENT1 APPROVED_
1 28-SEP-07
2 23-SEP-07
1 09-AUG-07
SQL> SELECT sum(nvl(po.No_POS,0)) over(order by mths.dt) Quantity ,
2 to_char(trunc(mths.dt,'MM') , 'MON-YYYY') "Month"
3 from
4 (select count(poh.segment1) No_POS
5 , to_char(trunc(poh.approved_date,'MM') , 'MM-YYYY') Month_PO
6 from po_headers_all poh
7 --where poh.type_lookup_code='BLANKET'
8 --and poh.approved_flag='Y'
9 --and poh.approved_date>=nvl(:P_FROM_DATE,poh.approved_date)
10 --and poh.approved_date<=nvl(:P_TO_DATE,poh.approved_date)
11 group by trunc(poh.approved_date,'MM'))po,
12 --date is changed here and no extra subquery needed
13 (SELECT add_months(sysdate-365, level) dt
14 from dual
15 --dates are HARDCODED here
16 connect by level < (months_between(sysdate,sysdate-365)+1)) mths
17 WHERE to_char(trunc(mths.dt,'MM') , 'MM-YYYY')= po.Month_PO(+)
18 order by mths.dt;
QUANTITY Month
0 OCT-2006
0 NOV-2006
0 DEC-2006
0 JAN-2007
0 FEB-2007
0 MAR-2007
0 APR-2007
0 MAY-2007
0 JUN-2007
0 JUL-2007
1 AUG-2007
3 SEP-2007
12 rows selected. -
I saved photos from my Macbook Pro onto my Iphone (using itunes, 4 years ago). My macbook is now dead and I need to get the photos I saved off of my iphone 3GS transferred to a pc. Any help... From my PC I can only access "internal storage"
The iphone is not a storage/backup device. The picture sycn is one way - computer to iphone. The photos are also reduced in size when synced to iphone so they are not of the original quality
It has always been very basic to always maintain a backup of your computer.
Have you failed to do this?
If so, not good at all, you can e-mail the pics to yourself - keep in mind they will never be of the original quality -
I accidentally changed a setting on my ipod touch and now it won't change back. I have had my ipod for more than two years and i dont know what to do. If i go to the apple store, would they fix it, or would i need to get a new one? If it could be fixed, how much would it cost?
If it is still under warranty you can call the 800 number to apple and enter the serial number and it will tell you if it is under warranty or not if not its like $30 basically for them to help or something like that it said today when i called...
Or take it to a genius bar if you have one near?
Or further explain what setting you are needing fixed back and im sure someone here can help you for free! -
Can i get month, quarterly, half yearly, yearly wise sales report basing on
hi,
sap gurus,
good evening to all,
how can i get month, quarterly, half yearly, yearly wise sales report basing on division and material.
is there any std transaction code for that.
customization is requried for that.
regards,
balaji.t
09990019711Standard SAP SD Reports:=
Statistic Group:
Purpose u2013 To capture data for Standard Reports, we require to activate Statistic Group as under:
--> Item category (Configuration)
--> Sales document type (Configuration)
--> Customer (Maintain in Master data)
--> Material (Maintain in Master data)
When you generate statistics in the logistics information system, the system uses the combination of specified statistics groups to determine the appropriate update sequence. The update sequence in turn determines for exactly which fields the statistics are generated.
Configuration:
IMG --> Logistics Information System (LIS) --> Logistics Data Warehouse --> Updating --> Updating Control --> Settings: Sales --> Statistics Groups -->
1. Maintain Statistics Groups for Customers
2. Maintain Statistics Groups for Material
3. Maintain Statistics Groups for Sales Documents
4. Assign Statistics Groups for Each Sales Document Type
5. Assign Statistics Groups for each Sales Document Item Type .....
All Standard Reports which are available are as under:
SAP Easy Access: Information Systems -> Logistics -> Sales and distribution ->
1. Customer -> Incoming orders / Returns / Sales / Credit memos / Sales activities / Customer master / Conditions / Credit Master Sheet
2. Material -> Incoming orders / Returns / Sales / Credit memos / Material master / ...
3. Sales organization -> Sales organization / Sales office / Sales employee
4. Shipping point -> Deliveries / Returns
5. SD documents -> Orders / Deliveries / Billing documents ...
& so on.
Regards,
Rajesh banka -
How to get data with out having any date/timestamp columns by year wise
hi,
how can i select years wise rows from tables,if that have not any date/timestamp column.Well Govind it quite depends on what is the data type of that column and the format in which it is stored.
If the data type is varchar2/varchar and all the values are in a uniform format then there is no problem. All you need to use is the to_date function to convert the supplied strings to default date format and then use to_char function to only extract the YY or YYYY or RR or RRRR aspect of the data.
For example: If the column is called 'hire_date' and it's data type is varchar2 and the entries in this column are all in a uniform format, say month,date,year like January,12,1999. What you need to do is convert this string to a default date value using to_date function, like to_date(hire_date,'format_model') In the format model mention the format of the hire_date string. The out put of this function can be fed into to_char to extract the year, like to_char(output_of_to_date,'YYYY')
I hope you got what I meant. Let me know if it was of any use. -
I have problem with my iphone as it is disable and need to get all my data as the phone needs at least 40 years to enable accessing it
If you have never connected the phone to iTunes and backed it up or used iCloud to backup your data, it is lost at this point.
The only way to get back into the phone is to restore it.
~Lyssa -
I haven't used an Apple computer for years. I need help getting started
I just bought a mac mini after 20 years using a PC. I need help getting started. Any beginning manuals out there? Thanks.
New User of Apple wrote:
I just bought a mac mini after 20 years using a PC. I need help getting started. Any beginning manuals out there? Thanks.
Welcome back. Do not overlook the Finder and individual application Help menu support. The links provided above are great starter references. With tongue in cheek, they also may not be as current as the OS X release on your mini, so expect some differences.
Here are a litany of keyboard short-cuts, last updated in June 2012, that may prove selectively beneficial.
For actions like copy(c), paste(v), cut(x), print(p), and select-all(a), substitute the command key instead of control key.
If you right click on a file, this menu will seem familiar. Press the option key and notice the menu changes. If you copy a file(s) from this menu, change to the destination and then press option with the right button menu to see copy file(s) changed to move file(s).
To quickly view a file's contents, left click on the file icon, then press the space bar.
The native file format for OS X is PDF. Thus, when you choose to print, you also have the option to save as PDF with web links preserved.
Enjoy your mini. -
Need help with Expressions to get the sum of rows between dates
Date Total
8/06/2010 $2000
8/10/2010 $5000
8/28/2010 $2500
9/10/2010 $5000
9/16/2010 $2000
9/25/2010 $7000
9/28/2010 $2500
I need sum of rows based on month. I have tried following syntax. It did not work, which is returning $0. Appreciate any help i get.
=sum(iif(Date.value>="8/01/2010" AND Date.value<="8/30/2010",Total.value,0))Hi RG K,
According to your description, you want to calculate sum of total based on month use expression, but the expression does not work. If that is the case, please refer to the following steps:
In design surface, right-click Insert and click Text Box.
Right-click inside of the text box, then click expression.
In Expression text box, type the expression like below:
=sum(iif(Fields!Date.Value>="8/01/2010" AND Fields!Date.Value<="8/30/2010",Fields!total.Value,CDec(0)))
In this expression, the data type of total is Decimal, so we need to convert 0 to Decimal use CDec() function. If data type of total is Double, we need to use CDbl() function.
The following screenshot is for your reference:
If you have any more questions, please feel free to ask.
Thanks,
Wendy Fu
Wendy Fu
TechNet Community Support
Maybe you are looking for
-
TestStand Simple OI does not close properly
Hi there. We have build a test system that is running TestStand 4.2 and the code modules are created with LabVIEW 9.0. The SW is running on a PC with Windows XP. We are currently using TestStand Simple Operator Interface (LabVIEW version) to run the
-
Publisher 2K3 and Acrobat 9 Distilling to pdf
I am getting an error everytime I try to distill a PDF from MS Publisher 2k3 - %%[ ProductName: Distiller ]%% %%[ Error: LucidaSans,Bold cannot be embedded because of licensing restrictions. ]%% %%[ Font vendor (B&H) does not permit this font to be e
-
How to create a report template
Hello Could anybody give the information/steps for creating a report template. Thanks.
-
How to select an item from a jspx file from a bean
Hi all, I have a creation.jspx page that create / modify employee infos. I selected an employee from a table and then, I want to be able to modify some attributes. So, I need to enable a "save" button in the jspx page when I select an employee. I cre
-
Displaying dynamic values in the list
hi I have a list of usernames in the table and I want to display it on the list (not selection list)...when I click any usernames, the corresponding user details are to be displayed on the items..can anyone say how to display the usernames in the lis