Issue in Query to find the Cumulative Values
Hi All,
I am developing one Query in which i have to show plant wise last 12 months status of audit.
In this audit i am able to show the types of audits say X,Y,Z perfectly.
But the thiing i want to calculate is the cumulative values of X,Y,Z before the last 12 months.
For Ex: Audit X Y Z Formula(X+Y-Z)
month1 10 20 30 0
month2 10 30 10 30
month12 20 40 20 40
month13 ***(X) ***(Y) ***(Z)..till
Like this i want to develop the report as per the requirement.
Please help how to resolve this issue.
Thanks in Advance.
Hi All,
I am developing one Query in which i have to show plant wise last 12 months status of audit.
In this audit i am able to show the types of audits say X,Y,Z perfectly.
But the thiing i want to calculate is the cumulative values of X,Y,Z before the last 12 months.
For Ex: Audit X Y Z Formula(X+Y-Z)
month1 10 20 30 0
month2 10 30 10 30
month12 20 40 20 40
month13 ***(X) ***(Y) ***(Z)..till
Like this i want to develop the report as per the requirement.
Please help how to resolve this issue.
Thanks in Advance.
Similar Messages
-
Issue with query to find the lag data
Hello PL/SQL Gurus/Experts,
I am not able to extract the data with the following table structure -
drop table T2;
create table T2(Stream, Trade, Fees) as select
'MECHNICAL', 'Primary', '5534500' from dual union all select
'ELECTRICAL', 'Secondary', '5285500' from DUAL union all select
'MECHNICAL', 'Secondary', '2364535' from dual union all select
'ELECTRICAL', 'Primary', '1734540' from DUAL union all select
'MBE', 'Secondary', '3424500' from dual union all select
'ELECTRONICS', 'Primary', '5004567' from DUAL union all select
'ELECTRONICS', 'Secondary', '4543200' from DUAL union all select
'COMPUTERS', 'Secondary', '5534500' from DUAL union all select
'CIVIL', 'Primary', '2345500' from DUAL union all select
'CIVIL', 'Secondary', '4456500' from DUAL union all select
'COMPUTERS', 'Primary', '9542500' from DUAL;I want to extract the data in following format -
Stream Trade Fees
MECHNICAL Primary 5534500
Secondary 2364535
ELECTRICAL Primary 1734540
Secondary 5285500
ELECTRONICS Primary 5004567
Secondary 4543200
CIVIL Primary 2345500
Secondary 4456500
MBE Primary
Secondary 3424500
Total 34693342Now if if i am using the following query -
SELECT CASE WHEN LAG(Stream||Trade) OVER (ORDER BY Stream, Trade, Fees) = Stream||Trade THEN NULL ELSE Stream END Stream
, CASE WHEN LAG(Stream||Trade) OVER (ORDER BY Stream, Trade, Fees) = Stream||Trade THEN NULL ELSE Trade END Trade
, CASE WHEN LAG(Fees) OVER (partition by Stream||Trade ORDER BY Stream, Trade, Fees) = Fees THEN NULL ELSE Fees END Fees
FROM ( select distinct Stream, Trade, Fees from T2 ORDER BY Stream, Trade, Fees);
SELECT NVL2(LAG(Trade) OVER (PARTITION BY Stream, Trade ORDER BY Stream, Trade, Fees),Null,Trade) Trade,
NVL2(LAG(Stream) OVER (PARTITION BY Stream, Trade ORDER BY Stream, Trade, Fees),Null,Stream) Stream,
Fees
from (select distinct Stream, Trade, Fees from T2)Kindly help me ...
Thank you all for your time and effort in advance.This way!!!
select a.stream2 stream, trade, sum(fees)
from (
select case row_number() over(partition by stream order by trade)
when 1 then stream
else 'Unknown' end stream2,trade, fees
from t2
order by stream, trade
) a
where a.stream2 != 'Unknown'
group by a.stream2, trade;
STREAM TRADE SUM(FEES)
ELECTRICAL Primary 1734540
MECHNICAL Primary 5534500
COMPUTERS Primary 9542500
MBE Primary
ELECTRONICS Primary 5004567
CIVIL Primary 2345500PS:- Use instead of {CODE}
Also, use != instead of <> while pasting the code on Forum. <> is converted to NULL or probably ignored. -
How to find the PREVIOUS value of a non-DB item?
I want to do a simple thing but found it impossible.
I want to find the previous value of a non-DB item in a form.
I tried creating a text item and populating it using PRE-TEXT-ITEM but that does not work.
WHEN-VALIDATE-ITEM does not work either because WVI fires only after item value has changed.
Any suggestions will be greatly appreciated.
Edited by: Channa on Apr 2, 2010 4:34 AMChanna wrote:
I want to do a simple thing but found it impossible.
I want to find the previous value of a non-DB item in a form.
I tried creating a text item and populating it using PRE-TEXT-ITEM but that does not work.
WHEN-VALIDATE-ITEM does not work either because WVI fires only after item value has changed.
Any suggestions will be greatly appreciated.
Edited by: Channa on Apr 2, 2010 4:34 AMPlease make it clear what is your requirement then possibly we can provide you a better answer
You can use Global variables for to store old values also on Post-query populate a value in separate field or Parameter -
Query to find the latest record with respect to the current status
Dear gurus
I have the following data in a table
Customernum
bkcode
reqtdate
Prevstat
currstat
The data will be like this
CustomerNum bkcode reqdate prevstat currstat
5900 1 03-Aug-12 0 1
5900 1 06-Aug-12 1 0
5900 5 22-Jun-12 0 1
If a customer has an issue to solved, a record is added with bkcode , register date and currstat will be 1
If the issue is resolved for the bookingcode,a new record is added, the currentstatus will become 0. and prev stat will show 1. Row no 1 and 2 reflects this case
If this table is queried for finding the unresolved issues. the output should be only the Last row of the above example. since issue with bookingcode 1 has been resolved
I have trying hard to get this thing confused what to use Lead or Max
Kindly guide meHi,
one way here:
WITH mytable(CustomerNum, bkcode, reqdate, prevstat, currstat)
AS
SELECT 5900, 1, TO_DATE('03-Aug-12', 'DD-Mon-YY'), 0, 1 FROM DUAL UNION ALL
SELECT 5900, 1, TO_DATE('06-Aug-12', 'DD-Mon-YY'), 1, 0 FROM DUAL UNION ALL
SELECT 5900, 5, TO_DATE('22-Jun-12', 'DD-Mon-YY'), 0, 1 FROM DUAL
SELECT CustomerNum, bkcode, reqdate, prevstat, currstat
FROM (SELECT a.*
, ROW_NUMBER() OVER (PARTITION BY CustomerNum, bkcode
ORDER BY reqdate DESC) AS rn
FROM mytable a
WHERE rn=1
AND currstat=1;
CUSTOMERNUM BKCODE REQDATE PREVSTAT CURRSTAT
5900 5 22-JUN-12 0 1Regards.
Al
Edited by: Alberto Faenza on Dec 18, 2012 5:23 PM
Changed again!! Previous logic was wrong -
Hi team,
I have the following query where i need to find the max value
[code]
with t as (
select 'L1' R_nm ,'Data' R_Data , 'Obj' R_Obj , 'Wd' r_prec , '2' val from dual
union all
select 'L1' , 'Data', 'Obj' , 'No', '4' from dual
union all
select 'L2' , 'Data', 'Obj' , 'No', '4' from dual )
select t.*, max(val) over(partition by r_nm,r_data,r_obj) rk from t
[/code]
My expected output should be
[code]
r_nm r_data r_obj r_prec val rk
L1 Data Obj Wd 2 1
L1 Data Obj No 4 2
L2 Data Obj Yes 1 1
[/code]
Thank YouHi,
It looks like you're not interested in the MAX at all. It looks like you want to rank the rows, such that the one with the lowest value is assigned the number 1, the row with the 2nd lowest values gets 2, ..., and the row with the N-th lowest value gets N. If doesn't matter if the MAX is 4, or 2, or 420.
Here's one way to do that:
SELECT t.*
, RANK () OVER ( PARTITION BY r_nm, r_obj
ORDER BY val
) AS rk
FROM t
ORDER BY r_nm, r_obj
, val
Depending on how you want to deal with ties, you might want to use ROW_NUMBER or DENSE_RANK instead of RANK. -
How to find the FND_PROFILE.VALUE(ORG_ID) in custom apex schema
Hi,
How to find the FND_PROFILE.VALUE('ORG_ID') from dual in custom schema......
Actually I have integrated Apex 4.2 version with EBS r12
select FND_PROFILE.VALUE('ORG_ID') from dual ; in apps schema I m getting 198 value
but the same query(select apps.FND_PROFILE.VALUE('ORG_ID') from dual ) in custom schema (XXCVBB) returning null value..
Is there any pre steps I have to do...
kindly provide the useful inputs to retrieve the profile value..........
Regards,
PavanHi,
fnd_profile.value('ORG_ID'); will fetch you value only if there is a organization assigned to any application [or only if its a single Org], being it custom application you should have used set policy context or mo_global.init to populate the global temporary table which will hold all the Org's which that specific user has access too.
in your custom code use MO_GLOBAL.SET_POLICY_CONTEXT('S','ORG ID WHICH YOU NEED TO SET');
after setting the policy context, you should be able to see value from fnd_profile.value('ORG_ID');
Hope this Helps!!
MO_GLOBAL.SET_POLICY_CONTEXT
This procedure has two parameters
p_access_mode
Pass a value "S" in case you want your current session to work against Single ORG_ID
Pass a value of "M" in case you want your current session to work against multiple ORG_ID's
p_org_id
Only applicable if p_access_mode is passed value of "S"
MO_GLOBAL.INIT
Purpose of mo_global.init :-
It will check if new Multi Org Security Profile is set, to decide if new Security Profile method will be used.
If the new MO security profile is set, then mo_global.init inserts one record, for each Organization in Org Hierarchy, in table mo_glob_org_access_tmp
Regards,
Yuvaraj -
Query to find the application user
Hi,
what is the query to find the application user in sql command?
I tried the below query
select app_user from dual;
app_user invalid identifierthanks.Use bind variable notation:
select :app_user from dualThis is a reduced example, right? Can't see any reason to run such a query instead of using one of the documented methods of referencing built-in substitution values.
Please try to use the documentation to answer such basic questions. -
Query to find the class name that has the maximum number of students ?
I need the query to find the [class Name] which has the most number of students. please look below at the tables
Students Table
StudentId StudentName ClassID
1 xxx 1
2 yyy 1
3 zzz 1
4 fff 2
5 ttt 2
Classes Table
ClassID ClassNane
1 CSHARP
2 JSHARP
The result should be : CSHARP
since there are 3 students in CSHARP and 2 students in JSHARP class
Appreciate your help
ThanksTry:
DECLARE @Classes TABLE (
ClassID INT identity(1, 1) PRIMARY KEY
,ClassName VARCHAR(50)
INSERT INTO @Classes (ClassName)
VALUES ('CSharp')
,('JSharp')
DECLARE @Students TABLE (
StudentID INT identity(1, 1) PRIMARY KEY
,StudentName VARCHAR(10)
,ClassID INT
INSERT INTO @Students (
StudentName
,ClassID
VALUES (
'xxx'
,1
'yyy'
,1
'zzz'
,1
'fff'
,2
'ttt'
,2
SELECT TOP (1)
WITH TIES C.ClassName
FROM @Classes C
INNER JOIN @Students S ON C.ClassID = S.ClassID
GROUP BY C.ClassID
,C.ClassName
ORDER BY COUNT(S.StudentID) DESC
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Create a query to find the open PO
Hi all,
I want to create a query to find the Open PO which GR is not complete or Open invoice.
But I don't know how can I get the value: still to be invocied ,still to be delivery .
I want to know which table I can find these information.
I know a T-code :ME2L can run this report, but the format is not user friendly,so I want to create a new query .Hi
No need to create any query to find an Open PO.
You can use ME2N or ME2L or ME2N with proper scope of list and selection parameter.
In scope of list you can use the ALV one to get the user friendly report, if you do not have the ALV then you can
create your own scope of list by following the steps.
1) press F1 and click on the customizing icon
2) Click the button W/O specifying the project
3) Click Define scope of list
4) Copy any scope of list for example BEST and rename it as BEST_ALV and Tick the check box AL on the Bottom
5) You can get this new scope of list in the tcods mentioned above and execute thereports.
6) Once you get the output you can modify the layoout to get the user friendly format. Also you can download into excel sheet.
Hope it helps
Thanks/karthik -
Query to get the Cumulative salary from EMP
SQL query to find out cumulative salary.
EX:
EMPNO ENAME SAL CUMSAL
1 AAAA 1500 1500
2 BBBB 1000 2500
3 CCCC 1250 3750Hi Madhan,
If you talking abt query to find the total sal of each employee i.e., SAL + CUMSAL then you can use the below query:
select a.empno,a.ename,a.sal + b.cumsal totalsal from
emp a, emp b
where a.empno = b.empno;
Regards,
Murali Mohan -
How to find the ASCII value of ' ?
how to find the ASCII value of ' using ASCII Function in SQL??
while i am trying this using syntax ASCII(''') the query is terminating at the second oneLokanath Giri wrote:
For your validation check this link
http://www.techonthenet.com/ascii/chart.php
Please don't just refer people to other non-oracle websites when the answer is so simple to give here as others have already done. -
User wants to get the cumulative values based on his input.
Hi
I am working one FI Report; the out put values are Cumulative values for Current, Previous years. I developed and it fetches the data last 3 years Cumulative years data without any input FYMonth based on SAPexits and varible offsets. But user wants to put Fiscal year Month as input. So he wants get the cumulative values based on his input. For example, If his input SEP'2005(062005), Then Query gives the Output Cumulative Value (I.e., Sum of Total values of Form APR'2005 to SEP'2005)
Please provide the solution
Thanks
MannevMannev,
You can try doing this.
1. If the user input is fiscal period(2005006) , you can create a customer exit variable which will take the user value (i_step =2), and change the variable value to 20005001. (this is a simple code where tye last 2 digits are replaced by 01).
if the user is entering calmonth, you can use FM - DATE_TO_PERIOD_CONVERT, to convert the month to fiscal period.
2. You can create a rkf with restrictions on time char based on the customer exit variable and the user entered variable.
-Saket -
Query to find the list of users having access to a particular scenario
Hi,
I am learning Hyperion Planning 9.2 x version. I wanted to know the query to find the list of users having access to Plan Iteration - 1 scenarion.
As I am new to Hyperion Essbase and Hyperion Planning, I am assuming these ideas work out to get the desired result.
1) As Hyperion Planning uses Relational DB to store the User Security information, we can query the list of users who is having access to Plan Iteration - 1 Scenario.
I am not sure if this solution works. Please correct me If I am wrong.
2) We can also query from the essbase editor to find out who all having access to this scenario.
If the above is correct, can you please provide me the query.
I am really need of this and I will be happy if any one provide the solution.
Thanks & Regards,
Upendra. BesthaHi,
If you are looking for some SQL to retrieve the access rights by member then you can use something like (SQL Server code though can easily be modified for Oracle)
SELECT usr.object_name as Username,mem.object_name as Member,
'Access Rights' = CASE acc.access_mode
WHEN -1 THEN 'None'
WHEN 1 THEN 'Read'
WHEN 2 THEN 'Write'
WHEN 3 THEN 'Write'
ELSE 'Unknown' END,
'Relation' = CASE acc.flags
WHEN 0 THEN 'Member'
WHEN 5 THEN 'Children'
WHEN 6 THEN 'Children (inclusive)'
WHEN 8 THEN 'Descendants'
WHEN 9 THEN 'Descendants (inclusive)'
ELSE 'Unknown' END
FROM
hsp_access_control acc, hsp_object mem, hsp_object usr
WHERE acc.object_id = mem.object_id
AND acc.user_id = usr.object_id
AND mem.object_name = 'Plan Iteration - 1'
Cheers
John
http://john-goodwin.blogspot.com/ -
How to find the RGB Values of a Color for Hyperion
When customizing your Hyperion forms, we come across situations where we need the exact RGB value of a given color. This article explains a simple technique to find the RGB values using MS Paint and the Calculator applications that come as standard applications with your operating system.
Here are the steps to find the exact RGB value of a given color.
1) View your Hyperion form using IE, scroll down until you see the color you want to find the RGB value and press the "Print Screen" button (in your keyboard).
2) Open MS Paint and click Edit -> Paste or simply Ctrl+V. What you saw in the browser will be copied as a new untitled image.
3) Select the Color Picker tool and click on an area that has the color you want to match.
4) Now go to Edit Colors... option and click on the "Define Custom Colors >>" button. The color you picked will be selected on this palette. At the bottom right hand corner you will see the Red, Green and Blue values you need. Note down the R,G,B values (given in decimal).
5) Now we need to find out the hexa-decimal values that correspond to those decimal values. This is where we use the simple Calculator. Open the Calculator application from Program -> Accessories. Switch to the scientific mode by clicking View ->Scientific.
6) By default it will be in the decimal number mode. Enter the R value (238 in this example) and click on the Hex radio button. The corresponding hexa-decimal value (EE in this case) will be shown in the dial.
The selected color in this case has the same value for R, G and B. (In fact, all shades of gray has the same values for R, G and B.) Therefore, the RGB value of the background color that we need is #eeeeee. Repeat step 6 to find out the hex value for the Green and Blue elements, if they are different.
Tip:
If you find it difficult to pick a color, zoom the image by pressing Ctrl+PageDown or using View -> Zoom -> Custom... option.These tips are to find the RGB color of HFM default row where row is text and text lines in data columns are also visible to business users as Yellow as an input cell. By applying the same RGB color you can apply the same color to your data cells or rows. This post shows how to identify color from any web view-able object.
Regards,
Manaf -
How do I find the closest value to a constant in an array
I have an array of floating numbers and I want to find a value in that array that is closest to a floating constant. For example if I have the array 5.9, 2.8, 3.7, 5.8, 6.9, and if I have the constant 5.4, how would I find the closest value to 5.4 in the array, which in this case would be 5.8. The only approach I can think of is to subtract each value in the array from 5.8 and find the minimum value of an array which would be created from the differences. Is there a better approach?
Thank you.Just be sure to take the absolute value of the difference and your proposed method is fine.
Maybe you are looking for
-
Hello I am using Mobile Application Studio 4.0SR1 with SP8 I have some trouble with the modification of the Volumes/Trade Spends Planning. - The first thing I don't understand, running the project step by step, is how a DLL can call back functions in
-
17 inch screen v 15 inch screen on a macbook pro
Hi there, I'm just about to buy a new macbook pro and planning to use it predominantly for editing on. I heard recently that there were problems with the size of the 17 inch screen on some mac laptops and that they were fragile and prone to breaking.
-
Windows 7 64 bit install error
I have Window's 7 & I run 64 bit. Well Every single time I try to install iTunes 9.2.1 it says that part of the installation failed & it won't let my iPod nano or my gen. 5 iPod run on iTunes. So far every iPod I've tried says no then it tells me to
-
Restart gets hung up on a blank screen with a little circle of black spokes that sequentially fade and recover in a spinning wheel effect. Computer turns off after power button is depressed for a few seconds. Computer turns on with a short press of t
-
How will i implement a query like this in Crystal Report?. select * from a where a.id not exist (select b.id from b where a.id = b.id)