SQL query - syntax help
Hi All,
I have a table that has 2 columns X, and Y.
create table temp(
x number(5);
y number (5);
);I am trying to write a query to check both columns, here is what I mean.
SELECT CASE
IF X = 1 AND Y = 0 THEN 3
IF X = 2 AND Y = 1 THEN 4
IF X = 4 AND Y IS NULL THEN 5
END AS STATUS
FROM .....temp ...etc.I know what I want but having problems with the syntax.
Thanks in Advance for your help.
I'm using Oracle 11g, SQL Dev 3.0
select case when x = 1 and y = 0 then 3
when x = 2 and y = 1 then 4
when x = 4 and y is null then 5
else null
end ans
from ...for more on the case syntax see either one of these links.
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/case_statement.htm
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/expressions004.htm
Similar Messages
-
Cluster bar chart- sql query please help-
Hi,
I am trying to create cluster bar chart and am stumped with this sql query.Any help is appreciated.
Here is my table
city region issue value
c1 north i1 y
c1 north i2 y
c2 north i1 n
c2 north i2 y
c3 south i1 y
c3 south i2 n
c4 east i1 n
c4 east i2 n
The bar chart will have 3 series, north south and east.
And labels will be i1 and i2. value will be number of times this issue was encountered(y) in this region.
How can I get something like this from the above table-
region issue count(yes)
north i1 1
north i2 2
south i1 1
south i2 0
east i1 0
east i2 0
thanksWITH table1 AS
(SELECT 1435177 qte_id, 2 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no
FROM dual
table2 AS
SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
FROM dual
SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
FROM
(SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
FROM table1 t1, table2 t2
WHERE t2.qte_id = t1.qte_id (+)
AND t2.seq_no = t1.seq_no(+)
ORDER BY 1,2
WHERE t1_seq_no IS NOT NULL
ORDER BY 1,2
QTE_ID T2_SEQ_NO DIFF
1435177 2 0
1435177 5 0
1435177 7 0
1435177 8 0
1435177 12 0
1435177 14 0 -
Hi All,
Could you please help me out the below SQL query tuning .
Temp table is having 1 Million records
Master table is having 60 Million records
Query :
SELECT B.*,U.ID, SD, LE, LAE
FROM client.Temp B, client.Master
U WHERE U.policyno = B.policyno
AND B.UPFLAG = 0
1. Indexes are created on both email columns and Upflag for both tables.
2. Gathered DBMS Stats for MASTER Table
Data is loading 100k/hour on production .When your query takes too long ...
When your query takes too long ...
HOW TO: Post a SQL statement tuning request - template posting
HOW TO: Post a SQL statement tuning request - template posting -
Passing parameter to a SQL query - Please help
Hi All,
I am new to JDBC. I have been trying to pass an external variable to an SQL Query.
The query is
String username1="le";
PreparedStatement pstmt = null;
pstmt = c.prepareStatement("select * from users where USER_NAME like '%?%'");
pstmt.setString(1, username1);
pstmt.executeQuery();
ResultSet rs = pstmt.getResultSet();
I am trying to retrieve values from the users table where the USER_NAME column value that is a String contains the supplied value username1.
I am using the question mark (?) character to pass the value from the variable username1. I am also using the '%' substitution character which matches for any number of characters. So, the above query should retrieve rows where the USER_NAME is something like "charles","leander","Elena" etc.( that contains "le")
I am getting the error:
SQLException: java.sql.SQLException: ORA-01006: bind variable does not exist
I changed the query to
PreparedStatement pstmt = null;
pstmt = c.prepareStatement("select * from users where USER_NAME like '% " + username1 + "%'");
//pstmt.setString(1, username1);
pstmt.executeQuery();
This time , it is not giving the error and retrieving properly.
But I want to use the original query and use the "pstmt.setString(1, username1); " . Is there any way of achieving this?
Please help.
Cheers,
charles_amhi,
try this...
String username1="%le%";
pstmt = c.prepareStatement("select * from users where USER_NAME like ?")
pstmt.setString(1,username1);
cheers,
rpk -
Hi All,
We have a native SQL query accessing Oracle database(given below).
Can anyone please let me know what this query is about and how can we fine tune the query?
SELECT O.OBJECT_NAME ,
H.SID,
HS.MACHINE,
HS.PROCESS,
W.SID,
WS.MACHINE,
WS.PROCESS,
H.CTIME,
W.CTIME,
WS.ROW_WAIT_OBJ#,
WS.ROW_WAIT_FILE#,
WS.ROW_WAIT_BLOCK#,
WS.ROW_WAIT_ROW#,
HP.SPID,
WP.SPID
FROM V$LOCK H, V$LOCK W, V$LOCK I, V$LOCK I2, ALL_OBJECTS O,
V$SESSION HS, V$SESSION WS, V$PROCESS HP, V$PROCESS WP
WHERE H.ID1 = W.ID1
AND H.SID <> W.SID
AND H.TYPE IN ('TX','DL')
AND H.REQUEST = 0
AND H.SID = I.SID
AND I.TYPE = 'TM'
AND I.ID1 = O.OBJECT_ID
AND I.ID1 = I2.ID1
AND W.SID = I2.SID
AND I2.TYPE = 'TM'
AND H.SID = HS.SID
AND W.SID = WS.SID
AND HS.PADDR = HP.ADDR
AND WS.PADDR = WP.ADDR
INTO :EXCL_LOCK_WAITERS-OBJ_NAME ,
:EXCL_LOCK_WAITERS-HOLDER_SID ,
:EXCL_LOCK_WAITERS-H_HOSTNAME ,
:EXCL_LOCK_WAITERS-HOLDER_PID ,
:HOLDER_PID ,
:EXCL_LOCK_WAITERS-WAITER_SID ,
:EXCL_LOCK_WAITERS-W_HOSTNAME ,
:EXCL_LOCK_WAITERS-WAITER_PID ,
:WAITER_PID ,
:EXCL_LOCK_WAITERS-HELD_SINCE ,
:EXCL_LOCK_WAITERS-WAITSSINCE,
:ROW_WAIT_OBJ,
:ROW_WAIT_FILE,
:ROW_WAIT_BLOCK,
:ROW_WAIT_ROW,
:H_PROCESS,
:W_PROCESS
ENDEXEC
Thanks in advance.
Neethu MohanHi Neethu,
It gives you an overwiew of blocking Oracle sessions.
1. In general, the SQL checks Oracle sessions (SID's) that were requirering a DML lock ('TM') and now holding row locks (TX) to prevent destructive interference of simultaneous conflicting DML or DDL operations. DML statements automatically acquire both table-level locks and row-level locks ('TX') => holders
It joins these with the sessions that are waiting of releasing the lock by the holders => waiters.
2. it retrieves the detail information wich Oracle process , the object (table) , it's row , block and file
are affected by the locks.
3. Normally, the locks are only hold for a short period of time. If you have blocking sessions it may be of a log running task (i.e. mass data update of a table) ; but it could also be a application bug due to improper handling of concurrent updates of the same object.
4. Tuning
V$tables are expensive to query: Why?
v$ tables are generally Oracle memory structures.
v$ tables are not read consistent.
v$ tables require latches to access -- cannot modify and read memory at the same
time.
heavy access to v$ tables like this may cause some serious heavy duty contention.
Especially if you self join V$lock several times.
So the best would be to save the contents of V$LOCK in some table:
Create table mylocks as select * from v$lock;
Use that table for self-joining and joins to the other tables.
You can also CTAS the other v$ tables to bypass the performance bottleneck while retrieving
v$ directly.
You can empty or drop the created tables any time for new data.
Because you want to investigate only lock hold for a longert time to copy the v$ memory structures into
physical tables is not a disadvantage. You certainly will wait longer on finishing your query
instead of copy them into the tables.
Hope this helped
yk -
Hi,
I have a question about the performace of this SQL query. I have to display only 8 rows from this query. How is this query will be executed? What happens if the inside query returns more than 500 rows? Will it slow down?
SELECT * FROM (SELECT prod_date, create_date, prod_name, priority, status FROM CUST_PROD
WHERE cust_id = 100 and Status in(1, 5) order by priority, prod_name ) WHERE ROWNUM < = 8
Thank you..Its hard to tell what effect more data will have on a query until it happens. As BluShadow pointed out you're not talking about huge amounts of data; with luck the numbers you mentioned will not make any difference.
It looks like you're using the inline view to a top N query. You could look into using the RANK() function to do something similar. -
I need to denormalize data in sql query, please help!
With the query
select ref, start_time, end_time, person
from appointments
I get, eg:
REF START_TIME END_TIME PERSON
1234 10:00 11:00 USER1
1234 10:00 11:00 USER2
The users want to see it like this:
REF START_TIME END_TIME PERSON
1234 10:00 11:00 USER1, USER2
How do I do this just in sql?
cheers
Tracey.Apologies, my mistake, I forgot to connect by the ref as well...
(Note: you can ignore the CAST to VARCHAR2(40) as that just helped me get the formatted output.)
SQL> ed
Wrote file afiedt.buf
1 with t as (select 1234 as ref, '10:00' as start_time, '11:00' as end_time, 'USER1' as person from dual union all
2 select 1234, '10:00', '11:00', 'USER2' from dual union all
3 select 345, '11:00', '12:00', 'USER3' from dual)
4 -- END OF TEST DATA
5 select ref, start_time, end_time, CAST(MAX(LTRIM(SYS_CONNECT_BY_PATH(person,', '),', ')) AS VARCHAR2(40)) as users
6 from (select ref, start_time, end_time, person
7 ,row_number() over (partition by ref, start_time, end_time order by person) rn
8 from t) t
9 CONNECT BY rn = PRIOR rn+1 AND ref = PRIOR ref
10 START WITH rn = 1
11* GROUP BY ref, start_time, end_time
SQL> /
REF START END_T USERS
1234 10:00 11:00 USER1, USER2
345 11:00 12:00 USER3
SQL> -
PL/SQL Function Syntax help please...
Can someone help me with the syntax here please? I am sure i am doing something wrong in my LOOP.
create or replace FUNCTION fcn_chk_dec(p_date number)
return NUMBER
as
--DECLARE
v_date NUMBER;
v_active NUMBER;
v_prev NUMBER;
v_delta NUMBER;
v_perc_delta NUMBER:
CURSOR c_prev_active IS
select date,people,
lag(people,1) over (order by date)
from stats
where date between to_date(p_date, 'YYYYMMDD')-2 and to_date(p_date, 'YYYYMMDD')-1
order by date desc
BEGIN
OPEN c_prev;
loop
FETCH c_prev INTO v_date,v_active,v_prev;
exit when c_prev%NOTFOUND;
v_delta:=v_active-v_prev;
v_perc_delta:=trunc((v_delta/v_active*100),2)
end loop;
close c_prev;
return v_perc_delta;
END fcn_chk_dec;what i am trying to do is create a funtion that will return one value for the first row that comes back.
here is my initial query. the reason i did not go with this query is because there are too many selects and i was told that's not good and slows down the system. Plus, i need to have a function call in another program that will access this function to compare it's output to a value in a table.
here was my initial start:
select date,people,delta,trunc((delta/people*100),2) as perc_delta
from (select date, people,people-prev_dly_people as delta
from
(select date,people,
lag(people,1) over (order by date) as prev_dly_people
from stats
where date between to_char(sysdate-2,'YYYYMMDD') and to_char(sysdate-1,'YYYYMMDD')
order by date desc))
basically, i have a table that has a total number of people. I want to get the percentage growth and decline from the most recent date and the date before it. This will give me a day to day percentage of people population change as of the most recent date.
I need this to be a function becaus i want to be able to pass any date i want into it and get the given delta percentage at the time for the people's population.
hope this makes sense. -
Hi experts,
what i want to do is write a single query which will show whether a employee
exits in the company or not.I have two tables emp and dept.There are as follows.
SQL> select * from emp;
NAME DEPTNO EMPNO
xxx 10 33036
YYY 12 2345
ZZZ 13 678
KKK 14 5678
RRR 15 7865
SQL> select * from dept;
DEPTNO LOCATION
10 AAA
11 BBB
12 CCC
13 DDD
what i want is it will select records from the emp table and find whether corrosponding
deptno really exists in the dept table.If the value is found in deptno column the dept table then it will set the value
Y other wise it will be N and all i have to do with the help of a single query.
expected result
name empno exists
xxx 33036 Y
YYY 2345 Y
ZZZ 678 Y
KKK 5678 N
RRR 7865 N
Please help.
Regards
RajatSELECT EMPNO, NAME , EMPNO , NVL( ( SELECT 'Y' FROM DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO),'N') EXIST
FROM EMP
ORDER BY 1
Demo
SQL> WITH EMP AS(
2 SELECT 'XXX' NAME , 10 DEPTNO ,33036 EMPNO FROM DUAL UNION
3 SELECT 'YYY', 12, 2345 FROM DUAL UNION
4 SELECT 'ZZZ', 13 ,678 FROM DUAL UNION
5 SELECT 'KKK', 14 ,5678 FROM DUAL UNION
6 SELECT 'RRR', 15 ,7865 FROM DUAL ),
7 DEPT AS(
8 SELECT 10 DEPTNO,'AAA' DNAME FROM DUAL UNION
9 SELECT 11 ,'BBB' FROM DUAL UNION
10 SELECT 12 ,'CCC' FROM DUAL UNION
11 SELECT 13 ,'DDD'FROM DUAL )
12 SELECT EMPNO, NAME , EMPNO , NVL( ( SELECT 'Y' FROM DEPT WHERE EMP.DEPTNO=DEPT.DEPTNO),'N')
EXIST
13 FROM EMP
14 ORDER BY 1
15 /
EMPNO NAM EMPNO E
678 ZZZ 678 Y
2345 YYY 2345 Y
5678 KKK 5678 N
7865 RRR 7865 N
33036 XXX 33036 Y
SQL> Edited by: Salim Chelabi on Dec 7, 2008 4:15 AM -
How to add pl sql query into help text of an item.
Hi
In my database i have added comments to the colums. I would like to use this comments in the help text of the items of my application. I have the query but when I use it in the help text attribute it does not execute the query, it presents the query.
Any ideas?It is probably too late now, but note that if you create your application using the Create Application Wizard and Application Models, based on User Interface Defaults created in the SQL Workshop, any column comments will automatically become application help text.
-
11g SQL query syntax/results differ from 10g
Hello,
A bit of an odd situation. We have a report in 10g that is working as expected and when we run the same report in 11g we slightly different results. The same physical tables and columns are being used between each report and the number of records (17) returned to OBI are the same. Both queries are pulling from the same database with the same user id. As there are differences in how 10g runs queries vs 11g, are there any odd behaviors that I should keep an eye out for in how 11g assembles the data that's returned from the db prior to presenting it on the Analysis?
10g Results (correct):
Region...............Actuals (Prior Qtr).....Up...........Plan Amount....................% of Plan
AP...........................10,489..............8,965..............................................................
Americas................114,208...........110,779..................6...........................1969411%
EMEA.....................26,799..............23,976..............................................................
UNASSIGNED....................................................149,957...........................0%
Grand Total.............151,496...........143,721..........149,962.........................96%
11g Results (incorrect):
Region...............Actuals (Prior Qtr).....Up...........Plan Amount....................% of Plan
AP...........................10,180..............8,965............................................................
Americas.................90,878...........110,779............................................................
EMEA.....................24,978.............23,976............................................................
UNASSIGNED....................................................149,957...........................0%
Grand Total.............126,037..........143,721..........149,957.........................96%
Thank you!
Mike
-------------------- 10g query--------------------------
-------------------- Sending query to database named EBS Rapid Data Store (id: <<5087545>>):
WITH
SAWITH0 AS (select T28761.PERIOD_NAME as c2,
T28761.PERIOD_START_DATE as c3,
T28761.QUARTER_RANK as c4,
ROW_NUMBER() OVER (PARTITION BY T28761.QUARTER_RANK ORDER BY T28761.QUARTER_RANK DESC) as c5
from
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ ),
SAWITH1 AS (select Case when case SAWITH0.c5 when 1 then SAWITH0.c3 else NULL end is not null then Rank() OVER ( ORDER BY case SAWITH0.c5 when 1 then SAWITH0.c3 else NULL end ASC NULLS LAST ) end as c1,
SAWITH0.c2 as c2,
SAWITH0.c4 as c3
from
SAWITH0),
SAWITH2 AS (select min(SAWITH1.c1) over (partition by SAWITH1.c3) as c1,
SAWITH1.c2 as c2
from
SAWITH1),
SAWITH3 AS (select distinct SAWITH2.c1 + 1 as c1,
SAWITH2.c2 as c2
from
SAWITH2),
SAWITH4 AS (select T28761.QUARTER_RANK as c2,
T28761.QUARTER_YEAR_NAME as c3,
T28761.PERIOD_START_DATE as c4,
ROW_NUMBER() OVER (PARTITION BY T28761.QUARTER_RANK ORDER BY T28761.QUARTER_RANK DESC) as c5
from
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ ),
SAWITH5 AS (select Case when case SAWITH4.c5 when 1 then SAWITH4.c4 else NULL end is not null then Rank() OVER ( ORDER BY case SAWITH4.c5 when 1 then SAWITH4.c4 else NULL end ASC NULLS LAST ) end as c1,
SAWITH4.c2 as c2,
SAWITH4.c3 as c3
from
SAWITH4),
SAWITH6 AS (select distinct min(SAWITH5.c1) over (partition by SAWITH5.c2) as c1,
SAWITH5.c2 as c2,
SAWITH5.c3 as c3
from
SAWITH5),
SAWITH7 AS (select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5,
D1.c6 as c6
from
(select sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c1,
SAWITH6.c3 as c2,
T41894.ICN_GROUP as c3,
SAWITH6.c2 as c4,
T41894.ICN_GROUP_CODE as c5,
T30728.PARENT_REGION as c6,
ROW_NUMBER() OVER (PARTITION BY T30728.PARENT_REGION, T41894.ICN_GROUP_CODE, SAWITH6.c2 ORDER BY T30728.PARENT_REGION ASC, T41894.ICN_GROUP_CODE ASC, SAWITH6.c2 ASC) as c7
from
SAWITH3 left outer join (
XXFI.XXFI_REVFCST_POL_REPORTING_V T37838 /* Fact_POL_Snapshot */ left outer join
XXFI.XXFI_GEO_REGION_ACCUM T30728 /* Dim_Regions */ On T30728.COUNTRY_CODE = T37838.SHIP_TO_COUNTRY_CODE2) left outer join
XXFI.XXFI_ICN_OWNERS_V T41894 /* Dim_ICN_Override */ On T37838.OVERRIDE_ICN = T41894.ICN_CODE) On SAWITH3.c2 = T37838.PERIOD_NAME,
SAWITH6
where ( SAWITH6.c1 = SAWITH3.c1 and SAWITH6.c3 = '2010-Q2' and (T37838.PROSPECT_NUMBER is null or T37838.PROSPECT_NUMBER not like '%Budget%') )
group by T30728.PARENT_REGION, T41894.ICN_GROUP_CODE, T41894.ICN_GROUP, SAWITH6.c2, SAWITH6.c3
) D1
where ( D1.c7 = 1 ) ),
SAWITH8 AS (select sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c1,
sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 50 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 50 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c2,
T30728.PARENT_REGION as c3,
T28761.QUARTER_YEAR_NAME as c6,
T41894.ICN_GROUP as c7,
T28761.QUARTER_RANK as c8,
T41894.ICN_GROUP_CODE as c9
from
XXFI.XXFI_REVFCST_POL_REPORTING_V T37838 /* Fact_POL_Snapshot */ left outer join
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ On T28761.PERIOD_NAME = T37838.PERIOD_NAME) left outer join
XXFI.XXFI_GEO_REGION_ACCUM T30728 /* Dim_Regions */ On T30728.COUNTRY_CODE = T37838.SHIP_TO_COUNTRY_CODE2) left outer join
XXFI.XXFI_ICN_OWNERS_V T41894 /* Dim_ICN_Override */ On T37838.OVERRIDE_ICN = T41894.ICN_CODE
where ( T28761.QUARTER_YEAR_NAME = '2010-Q2' and (T37838.PROSPECT_NUMBER is null or T37838.PROSPECT_NUMBER not like '%Budget%') )
group by T28761.QUARTER_YEAR_NAME, T28761.QUARTER_RANK, T30728.PARENT_REGION, T41894.ICN_GROUP_CODE, T41894.ICN_GROUP),
SAWITH9 AS (select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5,
D1.c6 as c6,
D1.c7 as c7,
D1.c8 as c8,
D1.c9 as c9
from
(select sum(SAWITH8.c1) over (partition by SAWITH8.c3) as c1,
sum(SAWITH8.c2) over (partition by SAWITH8.c3) as c2,
SAWITH8.c3 as c3,
sum(SAWITH8.c1) over (partition by SAWITH8.c8, SAWITH8.c9, SAWITH8.c3) as c4,
sum(SAWITH8.c2) over (partition by SAWITH8.c8, SAWITH8.c9, SAWITH8.c3) as c5,
SAWITH8.c6 as c6,
SAWITH8.c7 as c7,
SAWITH8.c8 as c8,
SAWITH8.c9 as c9,
ROW_NUMBER() OVER (PARTITION BY SAWITH8.c3, SAWITH8.c8, SAWITH8.c9 ORDER BY SAWITH8.c3 ASC, SAWITH8.c8 ASC, SAWITH8.c9 ASC) as c10
from
SAWITH8
) D1
where ( D1.c10 = 1 ) ),
SAWITH10 AS (select sum(T34877.AMOUNT) as c1,
T28761.QUARTER_YEAR_NAME as c3,
T30728.PARENT_REGION as c4,
T41894.ICN_GROUP as c5,
T28761.QUARTER_RANK as c6,
T41894.ICN_GROUP_CODE as c7
from
XXFI.XXFI_REVENUE_BUDGET_ACCUM T34877 /* Fact_Revenue_Budgets */ left outer join
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ On T28761.PERIOD_NAME = T34877.PERIOD_NAME) left outer join
XXFI.XXFI_GEO_REGION_ACCUM T30728 /* Dim_Regions */ On T30728.COUNTRY_CODE = T34877.SHIP_TO_COUNTRY_CODE2) left outer join
XXFI.XXFI_ICN_OWNERS_V T41894 /* Dim_ICN_Override */ On T34877.OVERRIDE_ICN = T41894.ICN_CODE
where ( T28761.QUARTER_YEAR_NAME = '2010-Q2' )
group by T28761.QUARTER_YEAR_NAME, T28761.QUARTER_RANK, T30728.PARENT_REGION, T41894.ICN_GROUP_CODE, T41894.ICN_GROUP),
SAWITH11 AS (select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5,
D1.c6 as c6,
D1.c7 as c7
from
(select sum(SAWITH10.c1) over (partition by SAWITH10.c4) as c1,
sum(SAWITH10.c1) over (partition by SAWITH10.c6, SAWITH10.c7, SAWITH10.c4) as c2,
SAWITH10.c3 as c3,
SAWITH10.c4 as c4,
SAWITH10.c5 as c5,
SAWITH10.c6 as c6,
SAWITH10.c7 as c7,
ROW_NUMBER() OVER (PARTITION BY SAWITH10.c4, SAWITH10.c6, SAWITH10.c7 ORDER BY SAWITH10.c4 ASC, SAWITH10.c6 ASC, SAWITH10.c7 ASC) as c8
from
SAWITH10
) D1
where ( D1.c8 = 1 ) ),
SAWITH12 AS (select T28761.PERIOD_NAME as c2,
T28761.PERIOD_START_DATE as c3,
T28761.QUARTER_RANK as c4,
ROW_NUMBER() OVER (PARTITION BY T28761.QUARTER_RANK ORDER BY T28761.QUARTER_RANK DESC) as c5
from
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ ),
SAWITH13 AS (select Case when case SAWITH12.c5 when 1 then SAWITH12.c3 else NULL end is not null then Rank() OVER ( ORDER BY case SAWITH12.c5 when 1 then SAWITH12.c3 else NULL end ASC NULLS LAST ) end as c1,
SAWITH12.c2 as c2,
SAWITH12.c4 as c3
from
SAWITH12),
SAWITH14 AS (select min(SAWITH13.c1) over (partition by SAWITH13.c3) as c1,
SAWITH13.c2 as c2
from
SAWITH13),
SAWITH15 AS (select distinct SAWITH14.c1 + 1 as c1,
SAWITH14.c2 as c2
from
SAWITH14),
SAWITH16 AS (select T28761.QUARTER_YEAR_NAME as c2,
T28761.PERIOD_START_DATE as c3,
T28761.QUARTER_RANK as c4,
ROW_NUMBER() OVER (PARTITION BY T28761.QUARTER_RANK ORDER BY T28761.QUARTER_RANK DESC) as c5
from
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ ),
SAWITH17 AS (select Case when case SAWITH16.c5 when 1 then SAWITH16.c3 else NULL end is not null then Rank() OVER ( ORDER BY case SAWITH16.c5 when 1 then SAWITH16.c3 else NULL end ASC NULLS LAST ) end as c1,
SAWITH16.c2 as c2,
SAWITH16.c4 as c3
from
SAWITH16),
SAWITH18 AS (select distinct min(SAWITH17.c1) over (partition by SAWITH17.c3) as c1,
SAWITH17.c2 as c2
from
SAWITH17),
SAWITH19 AS (select sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c1,
T30728.PARENT_REGION as c2
from
SAWITH15 left outer join (
XXFI.XXFI_REVFCST_POL_REPORTING_V T37838 /* Fact_POL_Snapshot */ left outer join
XXFI.XXFI_GEO_REGION_ACCUM T30728 /* Dim_Regions */ On T30728.COUNTRY_CODE = T37838.SHIP_TO_COUNTRY_CODE2) On SAWITH15.c2 = T37838.PERIOD_NAME,
SAWITH18
where ( SAWITH18.c1 = SAWITH15.c1 and SAWITH18.c2 = '2010-Q2' and (T37838.PROSPECT_NUMBER is null or T37838.PROSPECT_NUMBER not like '%Budget%') )
group by T30728.PARENT_REGION),
SAWITH20 AS (select T28761.PERIOD_NAME as c2,
T28761.PERIOD_START_DATE as c3,
T28761.QUARTER_RANK as c4,
ROW_NUMBER() OVER (PARTITION BY T28761.QUARTER_RANK ORDER BY T28761.QUARTER_RANK DESC) as c5
from
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ ),
SAWITH21 AS (select Case when case SAWITH20.c5 when 1 then SAWITH20.c3 else NULL end is not null then Rank() OVER ( ORDER BY case SAWITH20.c5 when 1 then SAWITH20.c3 else NULL end ASC NULLS LAST ) end as c1,
SAWITH20.c2 as c2,
SAWITH20.c4 as c3
from
SAWITH20),
SAWITH22 AS (select min(SAWITH21.c1) over (partition by SAWITH21.c3) as c1,
SAWITH21.c2 as c2
from
SAWITH21),
SAWITH23 AS (select distinct SAWITH22.c1 + 1 as c1,
SAWITH22.c2 as c2
from
SAWITH22),
SAWITH24 AS (select T28761.QUARTER_YEAR_NAME as c2,
T28761.PERIOD_START_DATE as c3,
T28761.QUARTER_RANK as c4,
ROW_NUMBER() OVER (PARTITION BY T28761.QUARTER_RANK ORDER BY T28761.QUARTER_RANK DESC) as c5
from
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ ),
SAWITH25 AS (select Case when case SAWITH24.c5 when 1 then SAWITH24.c3 else NULL end is not null then Rank() OVER ( ORDER BY case SAWITH24.c5 when 1 then SAWITH24.c3 else NULL end ASC NULLS LAST ) end as c1,
SAWITH24.c2 as c2,
SAWITH24.c4 as c3
from
SAWITH24),
SAWITH26 AS (select distinct min(SAWITH25.c1) over (partition by SAWITH25.c3) as c1,
SAWITH25.c2 as c2
from
SAWITH25),
SAWITH27 AS (select sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c1
from
SAWITH23 left outer join XXFI.XXFI_REVFCST_POL_REPORTING_V T37838 /* Fact_POL_Snapshot */ On SAWITH23.c2 = T37838.PERIOD_NAME,
SAWITH26
where ( SAWITH26.c1 = SAWITH23.c1 and SAWITH26.c2 = '2010-Q2' and (T37838.PROSPECT_NUMBER is null or T37838.PROSPECT_NUMBER not like '%Budget%') ) ),
SAWITH28 AS (select sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c1,
sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 50 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 50 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c2
from
XXFI.XXFI_REVFCST_POL_REPORTING_V T37838 /* Fact_POL_Snapshot */ left outer join
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ On T28761.PERIOD_NAME = T37838.PERIOD_NAME
where ( T28761.QUARTER_YEAR_NAME = '2010-Q2' and (T37838.PROSPECT_NUMBER is null or T37838.PROSPECT_NUMBER not like '%Budget%') ) ),
SAWITH29 AS (select sum(T34877.AMOUNT) as c1
from
XXFI.XXFI_REVENUE_BUDGET_ACCUM T34877 /* Fact_Revenue_Budgets */ left outer join
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ On T28761.PERIOD_NAME = T34877.PERIOD_NAME
where ( T28761.QUARTER_YEAR_NAME = '2010-Q2' ) )
select case when SAWITH7.c2 is not null then SAWITH7.c2 when SAWITH9.c6 is not null then SAWITH9.c6 when SAWITH11.c3 is not null then SAWITH11.c3 end as c1,
case when SAWITH9.c3 is not null then SAWITH9.c3 when SAWITH19.c2 is not null then SAWITH19.c2 when SAWITH7.c6 is not null then SAWITH7.c6 when SAWITH11.c4 is not null then SAWITH11.c4 end as c2,
case when SAWITH7.c3 is not null then SAWITH7.c3 when SAWITH9.c7 is not null then SAWITH9.c7 when SAWITH11.c5 is not null then SAWITH11.c5 end as c3,
SAWITH9.c5 / nullif( 1000, 0) as c4,
SAWITH7.c1 / nullif( 1000, 0) as c5,
SAWITH11.c2 / nullif( 1000, 0) as c6,
nvl(SAWITH9.c4 , 0) / nullif( nvl(SAWITH11.c2 , 0), 0) * 100 as c7,
case when SAWITH7.c4 is not null then SAWITH7.c4 when SAWITH9.c8 is not null then SAWITH9.c8 when SAWITH11.c6 is not null then SAWITH11.c6 end as c16,
case when SAWITH11.c7 is not null then SAWITH11.c7 when SAWITH9.c9 is not null then SAWITH9.c9 when SAWITH7.c5 is not null then SAWITH7.c5 end as c17,
SAWITH27.c1 as c19,
SAWITH28.c2 as c20,
SAWITH29.c1 as c21,
SAWITH28.c1 as c22,
SAWITH19.c1 as c23,
SAWITH9.c2 as c24,
SAWITH11.c1 as c25,
SAWITH9.c1 as c26
from
SAWITH7 full outer join SAWITH9 On SAWITH7.c5 = SAWITH9.c9 and nvl(SAWITH7.c4 , 88.0) = nvl(SAWITH9.c8 , 88.0) and nvl(SAWITH7.c4 , 99.0) = nvl(SAWITH9.c8 , 99.0) and nvl(SAWITH7.c6 , 'q') = nvl(SAWITH9.c3 , 'q') and nvl(SAWITH7.c6 , 'z') = nvl(SAWITH9.c3 , 'z')) full outer join SAWITH11 On SAWITH11.c7 = case when SAWITH7.c5 is not null then SAWITH7.c5 when SAWITH9.c9 is not null then SAWITH9.c9 end and nvl(SAWITH11.c4 , 'q') = nvl(case when SAWITH7.c6 is not null then SAWITH7.c6 when SAWITH9.c3 is not null then SAWITH9.c3 end , 'q') and nvl(SAWITH11.c4 , 'z') = nvl(case when SAWITH7.c6 is not null then SAWITH7.c6 when SAWITH9.c3 is not null then SAWITH9.c3 end , 'z') and nvl(SAWITH11.c6 , 88.0) = nvl(case when SAWITH7.c4 is not null then SAWITH7.c4 when SAWITH9.c8 is not null then SAWITH9.c8 end , 88.0) and nvl(SAWITH11.c6 , 99.0) = nvl(case when SAWITH7.c4 is not null then SAWITH7.c4 when SAWITH9.c8 is not null then SAWITH9.c8 end , 99.0)) full outer join SAWITH19 On nvl(SAWITH19.c2 , 'q') = nvl(case when SAWITH7.c6 is not null then SAWITH7.c6 when SAWITH9.c3 is not null then SAWITH9.c3 when SAWITH11.c4 is not null then SAWITH11.c4 end , 'q') and nvl(SAWITH19.c2 , 'z') = nvl(case when SAWITH7.c6 is not null then SAWITH7.c6 when SAWITH9.c3 is not null then SAWITH9.c3 when SAWITH11.c4 is not null then SAWITH11.c4 end , 'z'),
SAWITH27,
SAWITH28,
SAWITH29
order by c2
+++:cfa20000:cfa20015:----2013/08/14 10:31:12
-------------------- Query Status: Successful Completion
+++:cfa20000:cfa20015:----2013/08/14 10:31:12
-------------------- Rows 21, bytes 34272 retrieved from database query id: <<5087545>>
+++:cfa20000:cfa20015:----2013/08/14 10:31:12
-------------------- Physical query response time 27 (seconds), id <<5087545>>
+++:cfa20000:cfa20015:----2013/08/14 10:31:12
-------------------- Physical Query Summary Stats: Number of physical queries 1, Cumulative time 27, DB-connect time 0 (seconds)
+++:cfa20000:cfa20015:----2013/08/14 10:31:12
-------------------- Rows returned to Client 17
--------------------------------------------- 11g Query ----------------------------------------------------------
Sending query to database named EBS Rapid Data Store (id: <<2779207>>), connection pool named EBS XXFI Connection Pool, logical request hash 1334563, physical request hash 292e1532: [[
WITH
OBICOMMON0 AS (select T28761.PERIOD_NAME as c2,
T28761.PERIOD_START_DATE as c3,
T28761.QUARTER_RANK as c4,
ROW_NUMBER() OVER (PARTITION BY T28761.QUARTER_RANK ORDER BY T28761.QUARTER_RANK DESC) as c5,
T28761.QUARTER_YEAR_NAME as c6
from
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ ),
SAWITH0 AS (select Case when case D1.c5 when 1 then D1.c3 else NULL end is not null then Rank() OVER ( ORDER BY case D1.c5 when 1 then D1.c3 else NULL end ASC NULLS LAST ) end as c1,
D1.c2 as c2,
D1.c4 as c3
from
OBICOMMON0 D1),
SAWITH1 AS (select min(D1.c1) over (partition by D1.c3) as c1,
D1.c2 as c2
from
SAWITH0 D1),
SAWITH2 AS (select distinct D1.c1 + 1 as c1,
D1.c2 as c2
from
SAWITH1 D1),
SAWITH3 AS (select Case when case D1.c5 when 1 then D1.c3 else NULL end is not null then Rank() OVER ( ORDER BY case D1.c5 when 1 then D1.c3 else NULL end ASC NULLS LAST ) end as c1,
D1.c6 as c2,
D1.c4 as c3
from
OBICOMMON0 D1),
SAWITH4 AS (select distinct min(D1.c1) over (partition by D1.c3) as c1,
D1.c2 as c2,
D1.c3 as c3
from
SAWITH3 D1),
SAWITH5 AS (select sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c1,
D4.c2 as c2,
T41894.ICN_GROUP as c3,
T30728.PARENT_REGION as c4,
D4.c3 as c5,
T41894.ICN_GROUP_CODE as c6
from
SAWITH2 D6 left outer join (
XXFI.XXFI_REVFCST_POL_REPORTING_V T37838 /* Fact_POL_Snapshot */ left outer join
XXFI.XXFI_GEO_REGION_ACCUM T30728 /* Dim_Regions */ On T30728.COUNTRY_CODE = T37838.SHIP_TO_COUNTRY_CODE2) left outer join
XXFI.XXFI_ICN_OWNERS_V T41894 /* Dim_ICN_Override */ On T37838.OVERRIDE_ICN = T41894.ICN_CODE) On D6.c2 = T37838.PERIOD_NAME,
SAWITH4 D4
where ( D4.c1 = D6.c1 and D4.c2 = '2010-Q2' and (T37838.PROSPECT_NUMBER is null or T37838.PROSPECT_NUMBER not like '%Budget%') )
group by T30728.PARENT_REGION, T41894.ICN_GROUP_CODE, T41894.ICN_GROUP, D4.c2, D4.c3),
SAWITH6 AS (select sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 50 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 50 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c1,
sum(case when T37838.POL_VERSION_FLAG = 'C' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 then nvl(T37838.AMOUNT , 0) when T37838.PERIOD_NAME <> 'March-13' and T37838.FORECAST_PROBABILITY_PERCENT >= 75 and T37838.POL_VERSION_FLAG is null then nvl(T37838.AMOUNT , 0) else 0 end ) as c2,
T28761.QUARTER_YEAR_NAME as c3,
T41894.ICN_GROUP as c4,
T30728.PARENT_REGION as c5,
T28761.QUARTER_RANK as c6,
T41894.ICN_GROUP_CODE as c7
from
XXFI.XXFI_REVFCST_POL_REPORTING_V T37838 /* Fact_POL_Snapshot */ left outer join
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ On T28761.PERIOD_NAME = T37838.PERIOD_NAME) left outer join
XXFI.XXFI_GEO_REGION_ACCUM T30728 /* Dim_Regions */ On T30728.COUNTRY_CODE = T37838.SHIP_TO_COUNTRY_CODE2) left outer join
XXFI.XXFI_ICN_OWNERS_V T41894 /* Dim_ICN_Override */ On T37838.OVERRIDE_ICN = T41894.ICN_CODE
where ( T28761.QUARTER_YEAR_NAME = '2010-Q2' and (T37838.PROSPECT_NUMBER is null or T37838.PROSPECT_NUMBER not like '%Budget%') )
group by T28761.QUARTER_YEAR_NAME, T28761.QUARTER_RANK, T30728.PARENT_REGION, T41894.ICN_GROUP_CODE, T41894.ICN_GROUP),
SAWITH7 AS (select sum(T34877.AMOUNT) as c1,
T28761.QUARTER_YEAR_NAME as c2,
T41894.ICN_GROUP as c3,
T30728.PARENT_REGION as c4,
T28761.QUARTER_RANK as c5,
T41894.ICN_GROUP_CODE as c6
from
XXFI.XXFI_REVENUE_BUDGET_ACCUM T34877 /* Fact_Revenue_Budgets */ left outer join
XXFI.XXFI_GL_FISCAL_MONTHS_V T28761 /* Dim_Periods */ On T28761.PERIOD_NAME = T34877.PERIOD_NAME) left outer join
XXFI.XXFI_GEO_REGION_ACCUM T30728 /* Dim_Regions */ On T30728.COUNTRY_CODE = T34877.SHIP_TO_COUNTRY_CODE2) left outer join
XXFI.XXFI_ICN_OWNERS_V T41894 /* Dim_ICN_Override */ On T34877.OVERRIDE_ICN = T41894.ICN_CODE
where ( T28761.QUARTER_YEAR_NAME = '2010-Q2' )
group by T28761.QUARTER_YEAR_NAME, T28761.QUARTER_RANK, T30728.PARENT_REGION, T41894.ICN_GROUP_CODE, T41894.ICN_GROUP),
SAWITH8 AS (select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5,
D1.c6 as c6,
D1.c7 as c7,
D1.c8 as c8,
D1.c9 as c9,
D1.c18 as c18,
D1.c19 as c19,
D1.c20 as c20,
D1.c21 as c21,
D1.c22 as c22
from
(select 0 as c1,
case when D1.c2 is not null then D1.c2 when D2.c3 is not null then D2.c3 when D3.c2 is not null then D3.c2 end as c2,
case when D1.c3 is not null then D1.c3 when D2.c4 is not null then D2.c4 when D3.c3 is not null then D3.c3 end as c3,
case when D1.c4 is not null then D1.c4 when D2.c5 is not null then D2.c5 when D3.c4 is not null then D3.c4 end as c4,
case when D1.c5 is not null then D1.c5 when D2.c6 is not null then D2.c6 when D3.c5 is not null then D3.c5 end as c5,
nvl(D2.c2 , 0) / nullif( nvl(D3.c1 , 0), 0) * 100 as c6,
D3.c1 / 1000 as c7,
D1.c1 / 1000 as c8,
D2.c1 / 1000 as c9,
case when D1.c6 is not null then D1.c6 when D2.c7 is not null then D2.c7 when D3.c6 is not null then D3.c6 end as c18,
D2.c2 as c19,
D3.c1 as c20,
D1.c1 as c21,
D2.c1 as c22,
ROW_NUMBER() OVER (PARTITION BY case when D1.c2 is not null then D1.c2 when D2.c3 is not null then D2.c3 when D3.c2 is not null then D3.c2 end , case when D1.c3 is not null then D1.c3 when D2.c4 is not null then D2.c4 when D3.c3 is not null then D3.c3 end , case when D1.c4 is not null then D1.c4 when D2.c5 is not null then D2.c5 when D3.c4 is not null then D3.c4 end , case when D1.c5 is not null then D1.c5 when D2.c6 is not null then D2.c6 when D3.c5 is not null then D3.c5 end , case when D1.c6 is not null then D1.c6 when D2.c7 is not null then D2.c7 when D3.c6 is not null then D3.c6 end ORDER BY case when D1.c2 is not null then D1.c2 when D2.c3 is not null then D2.c3 when D3.c2 is not null then D3.c2 end ASC, case when D1.c3 is not null then D1.c3 when D2.c4 is not null then D2.c4 when D3.c3 is not null then D3.c3 end ASC, case when D1.c4 is not null then D1.c4 when D2.c5 is not null then D2.c5 when D3.c4 is not null then D3.c4 end ASC, case when D1.c5 is not null then D1.c5 when D2.c6 is not null then D2.c6 when D3.c5 is not null then D3.c5 end ASC, case when D1.c6 is not null then D1.c6 when D2.c7 is not null then D2.c7 when D3.c6 is not null then D3.c6 end ASC) as c23
from
SAWITH5 D1 full outer join SAWITH6 D2 On D1.c6 = D2.c7 and SYS_OP_MAP_NONNULL(D1.c4) = SYS_OP_MAP_NONNULL(D2.c5) and SYS_OP_MAP_NONNULL(D1.c5) = SYS_OP_MAP_NONNULL(D2.c6) ) full outer join SAWITH7 D3 On D3.c6 = case when D1.c6 is not null then D1.c6 when D2.c7 is not null then D2.c7 end and SYS_OP_MAP_NONNULL(D3.c4) = SYS_OP_MAP_NONNULL(case when D1.c4 is not null then D1.c4 when D2.c5 is not null then D2.c5 end ) and SYS_OP_MAP_NONNULL(D3.c5) = SYS_OP_MAP_NONNULL(case when D1.c5 is not null then D1.c5 when D2.c6 is not null then D2.c6 end )
) D1
where ( D1.c23 = 1 ) )
select D1.c1 as c1,
D1.c2 as c2,
D1.c3 as c3,
D1.c4 as c4,
D1.c5 as c5,
D1.c6 as c6,
D1.c7 as c7,
D1.c8 as c8,
D1.c9 as c9,
D1.c18 as c19,
D1.c19 as c21,
D1.c20 as c22,
D1.c21 as c23,
D1.c22 as c24
from
SAWITH8 D1
order by c4, c2, c5, c19, c3
[2013-08-14T10:38:15.000-05:00] [OracleBIServerComponent] [TRACE:2] [USER-34] [] [ecid: 54a0696aeaefab88:-d74da91:1406506ef2a:-8000-00000000000151e6,0:1:9:6:1] [tid: a093e700] [requestid: cc480014] [sessionid: cc480000] [username: ] -------------------- Query Status: Successful Completion [[
[2013-08-14T10:38:15.000-05:00] [OracleBIServerComponent] [TRACE:2] [USER-26] [] [ecid: 54a0696aeaefab88:-d74da91:1406506ef2a:-8000-00000000000151e6,0:1:9:6:1] [tid: a093e700] [requestid: cc480014] [sessionid: cc480000] [username: ] -------------------- Rows 17, bytes 27200 retrieved from database query id: <<2779207>>check the report for the columns which has incorrect values for any calculation, null handling.
also check whether there is a difference in logical SQL between 10g and 11g.
also check whether they are pointing to same db.
check for null handling or default value not being set in 11g.
try rebuilding the same report, to check the metrics individually verify they match with 10g. -
Table1
QTE_ID SEQ_NO
1435177 2
1435177 5
1435177 7
1435177 8
1435177 12
1435177 14
Table2
QTE_ID SEQ_NO CMMT_CURR_AMT
1435177 1 98500
1435177 2 98500
1435177 3 0
1435177 4 98500
1435177 5 98500
1435177 7 98500
1435177 8 98500
1435177 11 59300
1435177 12 59300
1435177 14 59300
The result should be
QTE_ID SEQ_NO CMMT_CURR_AMT
1435177 2 0 (where 0 = cmmt_curr_amt of seq 2 - cmmt_curr_amt of seq 1 from table 2)
1435177 5 0 (where 0 = cmmt_curr_amt of seq 5 - cmmt_curr_amt of seq 4 from table 2)
1435177 7 0 (where 0 = cmmt_curr_amt of seq 7 - cmmt_curr_amt of seq 5 from table 2)
1435177 8 0 (where 0 = cmmt_curr_amt of seq 8 - cmmt_curr_amt of seq 7 from table 2)
1435177 12 0 (where 0 = cmmt_curr_amt of seq 12 - cmmt_curr_amt of seq 11 from table 2)
1435177 14 0 (where 0 = cmmt_curr_amt of seq 14 - cmmt_curr_amt of seq 12 from table 2)
I have to get the difference of cmmt_curr_amt from the table2 from seq 14 to seq 12 for seq14 in table 1.
Please help me in writing the query.
Thanks in advance.
SrinivasWITH table1 AS
(SELECT 1435177 qte_id, 2 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no
FROM dual
table2 AS
SELECT 1435177 qte_id, 1 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 2 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 3 seq_no, 0 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 4 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 5 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 7 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 8 seq_no, 98500 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 11 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 12 seq_no, 59300 cmmt_curr_amt
FROM dual
UNION ALL
SELECT 1435177 qte_id, 14 seq_no, 59300 cmmt_curr_amt
FROM dual
SELECT qte_id, t2_seq_no, cmmt_curr_amt - cmmt_curr_lag diff
FROM
(SELECT t2.qte_id, t2.seq_no t2_seq_no, t1.seq_no t1_seq_no, cmmt_curr_amt, LAG(cmmt_curr_amt,1,0) OVER (PARTITION BY t2.qte_id ORDER BY t2.seq_no) cmmt_curr_lag
FROM table1 t1, table2 t2
WHERE t2.qte_id = t1.qte_id (+)
AND t2.seq_no = t1.seq_no(+)
ORDER BY 1,2
WHERE t1_seq_no IS NOT NULL
ORDER BY 1,2
QTE_ID T2_SEQ_NO DIFF
1435177 2 0
1435177 5 0
1435177 7 0
1435177 8 0
1435177 12 0
1435177 14 0 -
SQL query syntax error .......
I am using following query
SELECT PERNR VORNA NACHN GBDAT FROM PA0002
INTO CORRESPONDING FIELDS OF TABLE ITAB
WHERE UPPER( VORNA ) = UPPER( STRU_USERIP-VORNA )
AND ENDDA >= SY-DATUM
AND BEGDA <= SY-DATUM .
and I am geting syntax error as --
vorna is not valid comparison operator .
can anyone plz suggest me solution over this problem .Logic must be written,
The below logic is incomplete
Break your head and modify it
TABLES:pa0002.
DATA:itab TYPE TABLE OF pa0002.
DATA:wa TYPE pa0002.
DATA:lv_vorna TYPE pa0002-vorna.
DATA:ra_vorna TYPE RANGE OF pa0002-vorna.
DATA:wa_vorna LIKE LINE OF ra_vorna .
DATA:lv_index TYPE i.
DATA:offset TYPE i.
DATA:pa_vorna TYPE pa0002-vorna VALUE 'Frank'.
DATA:len TYPE i.
len = STRLEN( pa_vorna ).
MOVE pa_vorna TO lv_vorna.
TRANSLATE lv_vorna TO LOWER CASE.
wa_vorna-low = lv_vorna.
APPEND wa_vorna TO ra_vorna.
MOVE pa_vorna TO lv_vorna.
TRANSLATE lv_vorna TO UPPER CASE.
wa_vorna-low = lv_vorna.
APPEND wa_vorna TO ra_vorna.
wa_vorna-low = PA_VORNA.
APPEND wa_vorna TO ra_vorna.
TRANSLATE PA_VORNA TO LOWER CASE.
DO len TIMES.
lv_index = sy-index - 1.
offset = lv_index + 1.
DO len TIMES.
MOVE pa_vorna TO lv_vorna.
TRANSLATE lv_vorna+lv_index(offset) TO UPPER CASE.
wa_vorna-low = lv_vorna.
APPEND wa_vorna TO ra_vorna.
ADD 1 TO lv_index.
ENDDO.
ENDDO. -
What's wrong with this sql query? Help
hi
i am having difficulty executing this query
ResultSet s=st.executeQuery("select * from employee where iden = ?"+id);
here in my program st is statement obg
iden is attribute name in table
id i am getting at run time from user
please help...it says wrong number of parameters
thank youThat's correct, get rid of the Question mark. Questions marks are used in PreparedStatements, but they are also used in pattern matching. I am assuming the iden is the table identity. Therefore, I am assuming it is numeric. If so, you can't use the question mark because pattern matching is only done with strings. If you are treating your statement as a PreparedStatement, then you have done it wrong. (See the API) Here is a code snippet from the API:PreparedStatement pstmt =
con.prepareStatement("UPDATE EMPLOYEES SET SALARY = ? WHERE ID = ?");
pstmt.setBigDecimal(1, 153833.00)
pstmt.setInt(2, 110592)It seems you are using a Statement object, so, you need to get rid of that question mark.
tajenkins -
SQL Query, please help very urgent
I am a newbie is sql.
I have two tables called test_master and test_detail.
Both tables contains pos_id as common field.
In test_detail got sub_id and to get the people under a given pos_id, I join with pos_id of test_master.
In the where condition, when I give the pos_id, it's returning only
the first level. How can I get the second level and get all the levels?
Any help is highly appreciable.It's very urgent.
Looking forward to hear from you.
Thanks
NewbieOk, I am pasting the description of the master and detail in the order.
Master
EMPLOYEE_NO VARCHAR2(30)
ORGANIZATION_ID NUMBER(15)
ORGANIZATION_NAME VARCHAR2(240)
POSITION_ID NUMBER(15)
POSITION_NAME VARCHAR2(240)
Detail
POSITION_ID NUMBER(15)
SUBORDINATE_ID NUMBER(15)
ORGANIZATION_ID NUMBER(15)
POSITION_NAME VARCHAR2(50)
Here is the sql, I want to get all the subordinates under a given position_id of the master.
Looking forward to hear from you.
select a.employee_no,a.POSITION_ID,a.POSITION_NAME,a.EMPLOYEE_NAME,
b.position_id,b.subordinate_id from portal_employee_master_test a,
portal_structure_test b
where a.POSITION_ID = b.POSITION_ID and a.POSITION_ID='xyz'
and b.position_ID=a.POSITION_ID
Maybe you are looking for
-
Team Foundation Server 2013 MP discoveries not working.
We are standing up a TFS 2013 instance. We copied over our prod data to new hardware and performed the upgrade. The system seems to be working, testing is going on now. I brought in the Team Foundation Server 2013 Management Pack ver 1.0.0.1 into
-
OAS 4.0.8+8i on NT
We are recently testing a cartridge that runs OK on 3.0.1, on 4.0.8 in order to gain some speed. This is a CWEB cartridge. OAS is under priority scheduling (default). We do seem to get a 30K blob faster than on 3.0.1, but every 20 or so queries (same
-
Can I import a photo into a specific event folder?
When I import a photo into iPhoto 11 it goes into the latest import folder. Then I have to drag these photos all over the event screen to get them into the folder I want Is there a way to get iPhoto to import into a specific event folder? Sorry if th
-
Migration Assistant cant see other computer
I am trying to migrate some data from my Imac to my MacBook, but cant make the two machines connect. They are failing to connect by WifI My Macbook - when I click the "From a Mac, Time Machine backup etc" button can find my Imac. My Imac - when I cli
-
Converting PSE 6.0 Catalog to PSE 7.0
I just installed PSE 7.0. Initially, when I opened a project it prompted me to convert my PSE 6.0 catalog, but I wanted to change the location of the new project, so I cancelled, changed the location and created a new project. However, this time it d