Would Hierarchical query help compressing rows in the following table?
Hi,
I have a table which looks like the following
key1 sdt edt val1
1 1/1/2000 2/1/2000 1
1 2/1/2000 3/1/2000 1
1 3/1/2000 4/1/2000 2
1 4/1/2000 5/1/2000 2
1 5/1/2000 6/1/2000 2
1 6/1/2000 7/1/2000 3
1 7/1/2000 8/1/2000 1
basically for a given key between given dates it had a value, kinda historical
table. As you can see first two rows can be compressed into
one. First two rows should become one (1, 1/1/2000, 3/1/2000, 1) as it had same
values between first two rows. Same with the next three row
(1,3/1/2000,6/1/2000,2). I did this to get to the following result.
SELECT key1, MIN(sdt), MAX(edt), val1
FROM (SELECT LEVEL, SYS_CONNECT_BY_PATH( TO_CHAR(sdt,'yyyymmdd') , '/') path,
key1, sdt, edt, val1
FROM myt t1
START WITH sdt = (SELECT MIN(sdt) FROM myt t2 WHERE t2.key1 = t1.key1
AND t2.val1 = t1.val1)
CONNECT BY sdt = PRIOR edt
AND key1 = PRIOR key1
AND val1 = PRIOR val1
GROUP BY key1, SUBSTR(path,2,8), val1;
key1 sdt edt val1
1 1/1/2000 3/1/2000 1
1 3/1/2000 6/1/2000 2
1 6/1/2000 7/1/2000 3
1 7/1/2000 8/1/2000 1
I was wondering if there is a better way to do this. What would help to tune this.
Thanks in advance.
SQL> select * from level_test;
KEY1 ST_DT ED_DT VAL
1 01-JAN-2000 01-FEB-2000 1
1 01-FEB-2000 01-MAR-2000 1
1 01-MAR-2000 01-APR-2000 2
1 01-APR-2000 01-MAY-2000 2
1 01-MAY-2000 01-JUN-2000 2
1 01-JUN-2000 01-JUL-2000 3
1 01-JUL-2000 01-AUG-2000 1
7 rows selected.
SQL> select key1, val, min(st_dt) min, max(ed_dt) max
2 from (
3 select key1, val, st_dt, ed_dt,
4 add_months(ed_dt, -(row_number() over(partition by key1, val order by st_dt))) am
5 from level_test
6 )
7 group by key1, val, am
8 /
KEY1 VAL MIN MAX
1 1 01-JAN-2000 01-MAR-2000
1 1 01-JUL-2000 01-AUG-2000
1 2 01-MAR-2000 01-JUN-2000
1 3 01-JUN-2000 01-JUL-2000
SQL> select * from t;
KEY1 ST_DT ED_DT VAL
1 01-JAN-2000 01-FEB-2000 10
1 01-FEB-2000 01-MAR-2000 10
1 01-MAR-2000 01-APR-2000 10
1 01-APR-2000 01-MAY-2000 10
1 01-MAY-2000 01-JUN-2000 10
2 01-JAN-2000 01-FEB-2000 10
2 01-FEB-2000 01-MAR-2000 10
2 01-MAR-2000 01-APR-2000 11
2 01-APR-2000 01-MAY-2000 11
2 01-MAY-2000 01-JUN-2000 12
10 rows selected.
SQL> select key1, val, min(st_dt) min, max(ed_dt) max
2 from (
3 select key1, val, st_dt, ed_dt,
4 add_months(ed_dt, -(row_number() over(partition by key1, val order by st_dt))) am
5 from t
6 )
7 group by key1, val, am
8 /
KEY1 VAL MIN MAX
1 10 01-JAN-2000 01-JUN-2000
2 10 01-JAN-2000 01-MAR-2000
2 11 01-MAR-2000 01-MAY-2000
2 12 01-MAY-2000 01-JUN-2000Rgds.
Similar Messages
-
3.5 Query Designer has 'row' in the footer of results but 7.0 has 'page'
3.5 Query Designer has 'row' in the footer of results but 7.0 has 'page' is there a way to change 7.0 to have 'row' instead of 'page'? We would prefer to see how many rows of data we have. I didn't know if this was a parameter they may be able to be changed.
Thanks,
DianeI donot think there is way to display Row instead of Page.
Also in 7.0. It is based on cells. -
I want to check the main diffrence in Pop up block enabled and disabled.But,i don't get any difference.Would u please help me to understand the difference using one practical example of website
Here's two popup test sites.
http://www.kephyr.com/popupkillertest/test/index.html
http://www.popuptest.com/ -
So, what are the best settings to record in using Canon HD Vixia HG20 for easy migration into iMovee'11 v.9.0.9?
It would be most helpful to list what the best possible settings are.
frame rate?
format? FXP?I suggest filming in 30P with this camera. That should be the MXP setting.
You could also use 30i which would be the FXP setting.
You will get the best results in iMovie by shooting progressive. -
Would you please help me to open the account?
I got a account of : “ItunesAccount ***”I have been used this account for almost For many years, it all worked pretty good, but yesterday when I try to update some apps on app Store. It said that my account has been disabled. and I could not update my app. Just wondering what happened? Would you please help me to open the account? I will be appreciated.
<Edited By Host>This is a user-to-user forum and no-one here can take any direct action. You need to contact iTunes Support - your account may have been disabled for security reasons. Go to https://expresslane.apple.com ; select 'iTunes' in the first column and then 'iTunes Store' in the second column and proceed from there.
-
MERGE Statement - unable to get a stable set of rows in the source tables
OWB Client: 10.1.0.2.0
OWB Repository: 10.1.0.1.0
I am trying to create a MERGE in OWB.
I get the following error:
ORA-12801: error signaled in parallel query server P004 ORA-30926: unable to get a stable set of rows in the source tables
I have read the other posts regarding this and can't seem to get a fix.
The target table has a unique index on the field that I am matching on.
The "incoming" data doesn't have a unique index, but I have checked and confirmed that it is unique on the appropriate key.
The "incoming" data is created by a join and filter in the mapping and I'd rather avoid having to load this data into a new table and add a unique index on this.
Any help would be great.
Thanks
LauraHello Laura,
The MERGE statement does not require any constraints on its target table or source table. The only requirement is that two input rows cannot update the same target row, meaning that all existing target rows can be matched by at most one input row (otherwise the MERGE would be undeterministic since you don't know which of the input rows you would end up with in the target).
If a table takes ages to load (and is not really big) I suspect that your mapping is not running in set mode and that it performs a full table scan on source data for each target row it produces.
If you ARE running in set mode you should run explain plan to get a hint on what is wrong.
Regarding your original mapping, try to set the target operator property:
Match by constraint=no constraints
and then check the Loading properties on each target column.
Regards, Hans Henrik -
How to populate rows in the detail table of a form from another table.
please can someone help me here:
i have a master/detail page. the master data is created and then i would like to do this: when one goes to the detail page (when first created), i would like somehow to populate all the rows in the detail table from rows retrieved in another table (with conditions).
i am new to apex so if this is a stupid question i apologise in advance!Hi
Firstly, there are no stupid questions, we all start somewhere!
However, I could do with some more detail (or even better an example on apex.oracle.com). Please can you post exactly what you have so far and what you want to achieve with simple details of the tables involved.
It sound like you may need to create a custom process to populate the details. You say 'with conditions'... what conditions?
Cheers
Ben
http://www.munkyben.wordpress.com
Don't forget to mark replies helpful or correct ;) -
XMLIndex: finding indexed XPaths and the number of rows in the path table
Hi,
I am storing non-schema-based binary XMLs in an XMLType column in 11g (11.1.0.6.0) and would like to index the XMLs either partially or fully using XMLIndex. I'm expecting to have a large number (tens of millions) of XML documents and have some concerns about the size of the XMLIndex path table.
In short, I am worried that the path table might grow unmanageable large. In order to avoid this and to plan for table partitioning, I would like to create a report of all indexed XPaths in an XMLIndex and to find out how many times each path is actualized in the path table. I would do this for a representative XML sample.
I have been creating XMLIndexes with different exclude/include paths, gathering stats with DBMS_STATS (estimate_percent = 100) and selecting the number of rows in the path table through USER_TABLES.
If anyone knows a more straightforward way of doing this all advice is very much appreciated.
Best Regards,
Rasko LeinonenThanks Marco,
I managed to get out all indexed paths using the following SQL. It took a while to understand how the join the XDB.X$PT39CW6BJR8W4VVE0G0LLGA0OCR5 and XDB.X$QN39CW6BJR8W4VVE0G0LLGA0OCR5 tables together but got there in the end. This helps to clarify which XPaths are being currently indexed by the XMLIndex.
begin
for v_row in (select PATH from XDB.X$PT39CW6BJR8W4VVE0G0LLGA0OCR5)
loop
declare
v_i BINARY_INTEGER := 1;
v_id raw(8);
v_len BINARY_INTEGER := 2;
v_skip BINARY_INTEGER := 1;
begin
while v_i < utl_raw.length(v_row.path) and
v_i + v_len <= utl_raw.length(v_row.path)
loop
v_i := v_i + v_skip;
v_id := utl_raw.substr(v_row.path, v_i, v_len);
--dbms_output.put_line(v_id);
for v_row2 in (select LOCALNAME, flags from XDB.X$QN39CW6BJR8W4VVE0G0LLGA0OCR5
where ID = v_id )
loop
if rawtohex(v_row2.flags) = '01'
then
dbms_output.put('@');
end if;
dbms_output.put(v_row2.localname);
if v_i + v_len < utl_raw.length(v_row.path)
then
dbms_output.put('/');
end if;
end loop;
v_i := v_i + v_len;
end loop;
dbms_output.put_line('');
end;
end loop;
end;
Example output:
RUN
RUN/@accession
RUN/@alias
RUN/@instrument_model
RUN/@run_date
RUN/@run_center
RUN/@total_data_blocks
RUN/EXPERIMENT_REF
RUN/EXPERIMENT_REF/@accession
RUN/EXPERIMENT_REF/@refname
RUN/DATA_BLOCK
RUN/DATA_BLOCK/@name
RUN/DATA_BLOCK/@total_spots
RUN/DATA_BLOCK/@total_reads
RUN/DATA_BLOCK/@number_channels
RUN/DATA_BLOCK/@format_code
RUN/DATA_BLOCK/@sector
RUN/DATA_BLOCK/FILES
RUN/DATA_BLOCK/FILES/FILE
RUN/DATA_BLOCK/FILES/FILE/@filename
RUN/DATA_BLOCK/FILES/FILE/@filetype
RUN/RUN_ATTRIBUTES
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE/TAG
RUN/RUN_ATTRIBUTES/RUN_ATTRIBUTE/VALUE -
SUM two fileds from different rows from the same table
I would like to SUM two fileds from different rows from the same table but I don't know how to do that.
E.g.
BillingTransactionsIndex CreateDate UserType UserIndex TransType Reference Total Balance
2 6/5/2008 15:02 1 51 1 150 -288.2 -288.2
5 6/8/2008 11:55 1 51 1 157 -1.58674 -289.787
In the table above I want SUM fields Total and Balance for the first row and the the next row SUM 2nd row Total with 1st row Balance
Please help
ThanksSQL> with tbl as
2 (select 1 as ID, 90 as total from dual
3 union all
4 select 2 as ID, 23 as total from dual
5 union all
6 select 3 as ID, 15 as total from dual
7 union all
8 select 4 as ID, 20 as total from dual)
9 select id , total, sum(total) over (order by ID) as balance from tbl
10 /
ID TOTAL BALANCE
1 90 90
2 23 113
3 15 128
4 20 148
SQL> -
ORA-30926: unable to get a stable set of rows in the source tables
hi,
I am loading data from source table to target table in a interface.
Using LKM incremental update .
In the merge rows step , getting the below error.
30926 : 99999 : java.sql.SQLException: ORA-30926: unable to get a stable set of rows in the source tables
please help as what should be done to resolve this.Below is the query in the merge step...
when i run from SQL also, same error
SQL Error: ORA-30926: unable to get a stable set of rows in the source tables
30926. 00000 - "unable to get a stable set of rows in the source tables"
*Cause: A stable set of rows could not be got because of large dml
activity or a non-deterministic where clause.
*Action: Remove any non-deterministic where clauses and reissue the dml.
merge into TFR.INVENTORIES T
using TFR.I$_INVENTORIES S
on (
T.ORGANIZATION_ID=S.ORGANIZATION_ID
and T.ITEM_ID=S.ITEM_ID
when matched
then update set
T.ITEM_TYPE = S.ITEM_TYPE,
T.SEGMENT1 = S.SEGMENT1,
T.DESCRIPTION = S.DESCRIPTION,
T.LIST_PRICE_PER_UNIT = S.LIST_PRICE_PER_UNIT,
T.CREATED_BY = S.CREATED_BY,
T.DEFAULT_SO_SOURCE_TYPE = S.DEFAULT_SO_SOURCE_TYPE,
T.MATERIAL_BILLABLE_FLAG = S.MATERIAL_BILLABLE_FLAG,
T.LAST_UPDATED_BY = S.LAST_UPDATED_BY
,T.ID = TFR.INVENTORIES_SEQ.NEXTVAL,
T.CREATION_DATE = CURRENT_DATE,
T.LAST_UPDATE_DATE = CURRENT_DATE
when not matched
then insert
T.ORGANIZATION_ID,
T.ITEM_ID,
T.ITEM_TYPE,
T.SEGMENT1,
T.DESCRIPTION,
T.LIST_PRICE_PER_UNIT,
T.CREATED_BY,
T.DEFAULT_SO_SOURCE_TYPE,
T.MATERIAL_BILLABLE_FLAG,
T.LAST_UPDATED_BY
,T.ID,
T.CREATION_DATE,
T.LAST_UPDATE_DATE
values
S.ORGANIZATION_ID,
S.ITEM_ID,
S.ITEM_TYPE,
S.SEGMENT1,
S.DESCRIPTION,
S.LIST_PRICE_PER_UNIT,
S.CREATED_BY,
S.DEFAULT_SO_SOURCE_TYPE,
S.MATERIAL_BILLABLE_FLAG,
S.LAST_UPDATED_BY
,TFR.INVENTORIES_SEQ.NEXTVAL,
CURRENT_DATE,
CURRENT_DATE
) -
SUM two ROWS in the SAME Table
Hi,
I have a problem with this issue. I want to sum two rows from the same table, but I don´t know how to do that. I tried to do it with CTE, but always I get the same error "Ambiguous". I would like to ask you, if there is other manner to get that
data (sum two rows) and if it is possible to see examples about it.
Thank you in advanceHi Vaibhav,
I leave you my scrip:
USE Modelling
GO
--TABLE Aer_Lingus_Income_Statement
IF OBJECT_ID('Aer_Lingus_Income_Statement') IS NOT NULL
DROP TABLE Aer_Lingus_Income_Statement
GO
CREATE TABLE Aer_Lingus_Income_Statement
ID [nvarchar](255) NOT NULL,
Name_Account [nvarchar](255) NULL,
Company [nvarchar](255) NULL,
Level0_Account [nvarchar](255) NULL,
Level1_Account [nvarchar](255) NULL,
Level2_Account [nvarchar](255) NULL,
Level3_Account [nvarchar](255) NULL,
Level4_Account [nvarchar](255) NULL,
Level5_Account [nvarchar](255) NULL,
Level6_Account [nvarchar](255) NULL,
Level7_Account [nvarchar](255) NULL,
Level8_Account [nvarchar](255) NULL,
Year_2006 decimal (15,2) null,
Year_2007 decimal (15,2) null,
Year_2008 decimal (15,2) null,
Year_2009 decimal (15,2) null,
Year_2010 decimal (15,2) null,
Year_2011 decimal (15,2) null,
Year_2012 decimal (15,2) null,
Year_2013 decimal (15,2) null,
GO
ALTER TABLE Aer_Lingus_Income_Statement
ADD CONSTRAINT PK_Aer_Lingus_Income_Statement PRIMARY KEY (ID)
GO
INSERT INTO Aer_Lingus_Income_Statement
SELECT *
FROM Aer_Lingus_data_Income
IF OBJECT_ID('Aer_Lingus_Income_Statement_Historic') IS NOT NULL
DROP VIEW Aer_Lingus_Income_Statement_Historic
GO
CREATE VIEW Aer_Lingus_Income_Statement_Historic
as
Select Level0_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level0_Account ='Revenue'
Group by Level0_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Passenger revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Ancillary revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Other revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account= 'Cargo revenue' and Level0_Account ='Revenue'
Group by Name_Account
UNION ALL
Select Level0_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level0_Account ='Operating expenses'
Group by Level0_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Staff costs' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Depreciation, amortisation and impairment' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Aircraft operating lease costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Fuel and oil costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Maintenance expenses' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Airport charges' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='En-route charges' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Distribution costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Ground operations, catering and other operating costs' and Level0_Account ='Operating expenses'
Group by Name_Account
UNION ALL
Select Level1_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Level1_Account ='Other (gains)/losses - net' and Level0_Account ='Operating expenses'
Group by Level1_Account
UNION ALL
Select Name_Account , sum(Year_2006) as Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
Where Name_Account ='Employee profit share' and Level0_Account ='Operating expenses'
Group by Name_Account
GO
WITH sumasRevenue
AS (
SELECT Name_Account, ID
, sum(Year_2006) AS Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
WHERE Level0_Account = 'Revenue'
GROUP BY Name_Account, ID
WITH ROLLUP
, total
AS (
SELECT Y2006,Y2007 ,Y2008,Y2009 ,Y2010 ,Y2011 ,Y2012 ,Y2013
FROM sumasRevenue
WHERE Name_Account IS NULL
sumasOperatingExpensive
AS (
SELECT Name_Account, ID
, sum(Year_2006) AS Y2006, sum (Year_2007) as Y2007, sum (Year_2008) as Y2008, sum (Year_2009) as Y2009, sum (Year_2010) as Y2010,
sum (Year_2011) as Y2011, sum (Year_2012) as Y2012, sum (Year_2013) as Y2013
FROM Aer_Lingus_data_Income
WHERE Level0_Account = 'Operating expenses'
GROUP BY Name_Account, ID
WITH ROLLUP
, total1
AS (
SELECT Y2006,Y2007 ,Y2008,Y2009 ,Y2010 ,Y2011 ,Y2012 ,Y2013
FROM sumasOperatingExpensive
WHERE Name_Account IS NULL
SELECT distinct ID , s.Name_Account,
(s.Y2006* 1.0 - t.Y2006) AS [V2006] ,(s.Y2007* 1.0 -T.Y2007 ) as [V2007] , (s.Y2008* 1.0 /T.Y2008 ) as [V2008],(s.Y2009* 1.0 /T.Y2009 ) as [V2009],
(s.Y2010* 1.0 /T.Y2010 ) as [V2010],(s.Y2011* 1.0 /T.Y2011 ) as [V2011],(s.Y2012* 1.0 /T.Y2012 ) as [V2012],(s.Y2013* 1.0 /T.Y2013 ) as [V2013]
FROM sumasRevenue AS s , sumasOperatingExpensive AS t
Where ID IS NOT NULL
UNION ALL
SELECT distinct ID,COALESCE(s.Name_Account,'NON CURRENT ASSETS') AS Name_Account ,
sum (s.Y2006* 1.0 / t.Y2006) as V2006,sum (s.Y2007* 1.0 / t.Y2007) as V2007,sum (s.Y2008* 1.0/ t.Y2008) as V2008,sum (s.Y2009* 1.0/ t.Y2009) as V2009,sum (s.Y2010* 1.0/ t.Y2010) as V2010,
sum (s.Y2011* 1.0 / t.Y2011) as V2011,sum (s.Y2012* 1.0/ t.Y2012) as V2012,sum (s.Y2013* 1.0/ t.Y2013) as V2013
FROM sumasRevenue as s , sumasOperatingExpensive as t
Where ID IS NULL and Name_Account IS NULL
GROUP BY Name_Account, ID
WITH ROLLUP
select *
from Aer_Lingus_Income_Statement_Historic
Thank you in advance -
Read first row of the internal table
Dear All,
Please let me know how to read the first row of the internal table?
I used following read statement but it is not working
READ TABLE t_cdhdr INDEX 1.Hi,
i think you are not reading an internal table
according to your code i think you are reading a type
which may be declared as types...
types are declared just for reference
eg
types: begin of t_cdhdr .
include strucuture cdhdr .
types: end of t_cdhdr .
types: t_it_cdhdr type standard table of t_cdhdr.
data: git_t_cdhdr type t_it_cdhdr.
data: gwa_t_cdhdr type t_cdhdr.
now have to fill the iternal table
and
read table git_t_cdhdr into gwa_t_cdhdr index 1.
reward points if helpful
thanks & regards,
venkatesh -
MERGE error : unable to get a stable set of rows in the source tables
Hi,
For an update, the following MERGE statement throws the error-unable to get a stable set of rows in the source tables:
MERGE INTO table2t INT
USING (SELECT DISTINCT NULL bdl_inst_id,.......
FROM table1 ftp
WHERE ftp.gld_business_date = g_business_date
AND ftp.underlying_instrument_id IS NOT NULL) ui
ON ( ( INT.inst_id = ui.inst_id
AND g_business_date BETWEEN INT.valid_from_date
AND INT.valid_to_date
OR ( INT.ric = ui.ric
AND g_business_date BETWEEN INT.valid_from_date
AND INT.valid_to_date
OR ( INT.isin = ui.isin
AND g_business_date BETWEEN INT.valid_from_date
AND INT.valid_to_date
OR ( INT.sedol = ui.sedol
AND g_business_date BETWEEN INT.valid_from_date
AND INT.valid_to_date
OR ( INT.cusip = ui.cusip
AND g_business_date BETWEEN INT.valid_from_date
AND INT.valid_to_date
WHEN MATCHED THEN
UPDATE
SET INT.inst_id = ui.inst_id, INT.ric = ui.ric
WHEN NOT MATCHED THEN
INSERT (inst_key, ......)
VALUES (inst_key, ......);
To determine the existence of a record, first check if any match is found on the first key, if not then search for the second key and so on.
Now two records with differenct first key, i.e. inst_id, can have the same ric(second key). On a rerun, with the target table already populated, the code fails. The reason is it finds duplicate entries for the second key.
Any suggestions on how to make this work?
Thanks in advance.
AnnieAnnie
You've spotted the problem (that two records have the same RIC). MERGE doesn't allow that; each record in the data being updated is only allowed to be updated once.
Is there a PK column (or columns) that we can rely on?
What you can try is to outer join FTP to INT. Something like:
MERGE INTO INT int1
USING (
select columns_you_need
from (
select ftp.columns -- whatever they are
, int2.columns
, row_number() over (partition by int2.pk_columns order by int2.somecolumns) as rn
from ftp
left join int int2
on (the condition you used in your query)
where rn=1
) s
WHEN MATCHED THEN UPDATE ...
WHEN NOT MATCHED THEN INSERT ...So if you can restrict the driving query so that only the first one of the possible updates actually gets presented to the MERGE operation, you might be in with a chance :-)
And of course this error is nothing to do with any triggers.
HTH
Regards Nigel -
ORA-30926: unable to get a stable set of rows in the source table
When user are trying to open a form getting below error.
com.retek.platform.exception.RetekUnknownSystemException:ORA-30926: unable to get a stable set of rows in the source tables
Please advice
Edited by: user13382934 on Jul 9, 2011 1:32 PMPlease try this
create table UPDTE_DEFERRED_MAILING_RECORDS nologging as
SELECT distinct a.CUST_ID,
a.EMP_ID,
a.PURCHASE_DATE,
a.drank,
c.CONTACT_CD,
c.NEW_CUST_CD,
a.DM_ROW_ID
FROM (SELECT a.ROWID AS DM_ROW_ID,
a.CUST_ID,
a.EMP_ID,
a.PURCHASE_DATE,
dense_rank() over(PARTITION BY a.CUST_ID, a.EMP_ID ORDER
BY a.PURCHASE_DATE DESC, a.ROWID) DRANK
FROM deferred_mailing a) a,
customer c
WHERE a.CUST_ID = c.CUST_ID
AND a.EMP_ID = c.EMP_ID
AND (a.PURCHASE_DATE <= c.PURCHASE_DATE OR
c.PURCHASE_DATE IS NULL)
and a.drank=1;
The query you've posted is behaving according to the expectations. The inner select is returning one row and the outer is returning two as the
WHERE a.CUST_ID = c.CUST_ID
AND a.EMP_ID = c.EMP_ID
AND (a.PURCHASE_DATE <= c.PURCHASE_DATE OR
c.PURCHASE_DATE IS NULL)
conditions are seeing two rows in the table customer.
I've added the a.drank=1 clause to skip the duplicates from the inner table and distinct in the final result to remove duplicates from the overall query result.
For eg, if you have one more row in the deferred_mailing like this
SQL> select * from DEFERRED_MAILING;
CUST_ID EMP_ID PURCHASE_
444 10 11-JAN-11
444 10 11-JAN-11
then the query without "a.drank=1" will return 4 rows like this by the outer query.
CUST_ID EMP_ID PURCHASE_ DM_ROW_ID DRANK C N
444 10 11-JAN-11 AAATi2AAGAAAACcAAB 2 Y Y
444 10 11-JAN-11 AAATi2AAGAAAACcAAA 1 Y Y
444 10 11-JAN-11 AAATi2AAGAAAACcAAB 2 Y Y
444 10 11-JAN-11 AAATi2AAGAAAACcAAA 1 Y Y
It'll return the below even if we use distinct on the same query(i.e. without a.drank=1)
CUST_ID EMP_ID PURCHASE_ DM_ROW_ID DRANK C N
444 10 11-JAN-11 AAATi2AAGAAAACcAAB 2 Y Y
444 10 11-JAN-11 AAATi2AAGAAAACcAAA 1 Y Y
which contains duplicates again.
So, we need a combination of distinct and dense here.
btw, Please mark the thread as 'answered', if you feel you got your question answered. This will save the time of others who search for open questions to answer.
Regards,
CSM -
How to refresh a child table each time I select a row in the master table
I've 2 tables, a master table and a child table.
When i click on each row of the master table, the child table needs to be refreshed.
I've given the id of table1(master) as the CreatePartialTrigger value in table2(child).
The refresh does happen but it happens in an inconsistent manner.
For eg. in my scenario,
1.I add a row to the master table
2.Click on the create button of the child table, this opens a popup and i enter a few values and the child row gets added.
3.Now when i toggle between the rows in my master table, the refresh does not happen and I see duplicate rows in the child table but in the datebase only one record gets stamped..
Is there any clean way to refresh the child table based on the row selection in the master table.
Kindly let me know.
Table1
<fnd:applicationsTable tableId="table">
<af:table value="#{bindings.Actions1.collectionModel}" var="row"
rows="#{bindings.Actions1.rangeSize}"
fetchSize="#{bindings.Actions1.rangeSize}"
selectedRowKeys="#{bindings.Actions1.collectionModel.selectedRow}"
selectionListener="#{bindings.Actions1.collectionModel.makeCurrent}"
rowSelection="single" id="table1"
contentDelivery="immediate" editingMode="clickToEdit"
columnSelection="multiple" autoHeightRows="10"
summary="#{HcmActionsTopGenBundle['Header.Action.ActionCode']}" rowBandingInterval="0"
styleClass="AFStretchWidth"
partialTriggers="::create ::createMenuItem">
<af:column id="column1" headerText=" " width="5"
rowHeader="true"/>
<af:column sortProperty="ActionCode" sortable="true"
headerText="#{bindings.Actions1.hints.ActionCode.label}" width="150"
showRequired="true" rendered="true" id="c1">
<af:inputText value="#{row.bindings.ActionCode.inputValue}"
label="#{bindings.Actions1.hints.ActionCode.label}"
required="#{bindings.Actions1.hints.ActionCode.mandatory}"
columns="#{bindings.Actions1.hints.ActionCode.displayWidth}"
maximumLength="#{bindings.Actions1.hints.ActionCode.precision}"
shortDesc="#{bindings.Actions1.hints.ActionCode.tooltip}" id="it1"
autoSubmit="true"
/>
</af:column>
</fnd:applicationsTable>
Table 2
<fnd:applicationsTable tableId="table2"
styleClass="AFStretchWidth"
id="AT2"
actionsMenuRendered="false"
secondaryToolbarRendered="false"
createPatternType="secondaryWindow"
createText="#{hcmActionsBundle['Action.Add']}"
createAction="#{backingBeanScope.SetupUiBean.invokeCreatePopUp}"
createPopupId="create1"
editEnabled="false"
createPartialTriggers="table1"Hi Frank,
As you mentioned I already have the id of my master table which is 'table1' as the createPartialTrigger in my child table.
In my case there are 2 scenarios.
I add a row to the Master table and when I click on the create button on the chile table, I get a pop with 'Yes' , 'No' and 'Cancel'
Scenario1
If I click 'Yes' , then I get another popup where I enter the values for the ActionReasonsActionReasonUsagesVO which is a combination of the ActionReasonsEO and the ActionReasonUsagesEO, now when I click on OK, a new row gets created in the ActionReasonsActionReasonUsagesVO.
In the above scenario things work fine, as I toggle between the rows in the Master table the child table gets refreshed.
Scenario2
If I click 'No' I get a search popup where I can query up the ActionReasonsVO and select existing data,on clicking OK, the values get mapped from the ActionReasonsVO to the ActionReasonsActionReasonUsagesVO.
Now when I toggle between the rows in my master table, I observe 2 types of behaviors
1.Due to incorrect refresh, the child table rows vanishes from the UI.
2.There are duplicate rows in the child table.
The issue is specific to this scenario where the refresh of the child table rows does not happen correctly.
Edited by: 944295 on Apr 18, 2013 5:16 PM
Maybe you are looking for
-
Problem: logical system has been changed once it has already been assinged
hai, we have started ebp configuration with a fresh client.and we assinged logical systems,but unfortunately someone has worked in the same client and made his own logical name...but later in console transaction the system promts that you have no bac
-
Has anyone experienced their iphone5 randomly shuts off without warning?
i often have this problem with my iphone5, it just turns off randomly without warning. i press the home button and the sleep/wake button at the same time to turn it on again. i thought at first it was a batterry issue, but the thing is it happens ran
-
hi all, I am making a BDC program, for tcode MM01 I have done the recording, and generated the program. I have a txt file on my desktop, and i am filling the internal table declared in the program from that txt file. Its working fine uptill now. Can
-
How can a trusted applet get permissions on server
Hello all, I have just now read some tutorial about Trusted Applet and not even experimented one. So my knowledge is absolutely zero. I would like to use Trusted Applets in my environment which I describe below: I have a database server on a Linux ma
-
SqlDeveloper View/Files menuItem freezes the View window
I have installed SQLDeveloper ver 3.1.07 on a Win7 64-bit OS. But I cannot get the View/Files window to work. As soon as I try to drill down a folder it hangs ny showing a child node saying "loading...". This also screws up my Connections window so t