Need Sql Query that Suppress the repeating rows.
Hi Sir,
I have below data set.
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
10 2450 1300
10 5000 1300
20 800 800
20 1100 800
20 2975 800
20 3000 800
30 800 800
30 1100 800
30 2975 800
40 3000 800
40 4000 900
I Need SQL query that can remove the duplicate or suppress.Just like below data set.
Output:
DeptID Sum(SAL) Avg(Sal)
10 1300 1300
2450 1300
5000 1300
20 800 800
1100 800
2975 800
3000 800
800 800
30 1100 800
2975 800
40 3000 800
4000 900
Could you please help me on this..
Your requiremnt is more of a reporting request which should not be handled in SQL. For example in SQL Plus you can use the BREAK command
SQL> break on deptno
SQL> select deptno, ename from emp order by deptno;
DEPTNO ENAME
10 KING
CLARK
20 JONES
SCOTT
SMITH
ADAMS
30 TURNER
MARTIN
WARD
ALLEN
BLAKE
11 rows selected.
SQL>
But if you still wish to do it in SQL you can use ROW_NUMBER analytic function and achieve it like this
select decode(rno, 1, deptno) deptno
, ename
from (
select row_number() over(partition by deptno order by ename) rno
, deptno
, ename
from emp
Similar Messages
-
I need a query that returns the average amount of characters for a text colum in MS SQL.
I need a query that returns the average amount of characters
for a text colum in MS SQL.
Could someone show me how?Sorted, i need the
DATALENGTH
function -
I need a query that selects the amount of records for each day in a table.
I need a query that selects the amount of records for each
day in a table.
Eg the result would be:
date 1 14
date 2 3
etc
Any ideas?sorted:
SELECT count([commentID]),convert(varchar, dateAdded, 112)
FROM COMMENTSgroup by convert(varchar, dateAdded,
112) -
Need SQL query to get the result.
Region
Month
Trx Type
Resolution Summary
AMERICAS
May-13
Adjustments
Correct
EMEA
May-13
Adjustments
Incorrect
AMERICAS
May-13
Credit Memo
Incorrect
EMEA
May-13
Invoice
Correct
AMERICAS
May-13
Credit Memo
Correct
OFD
May-13
Adjustments
Correct
AMERICAS
May-13
Invoice
Incorrect
LAD
May-13
Adjustments
Correct
LAD
May-13
Adjustments
Correct
OFD
May-13
Adjustments
Correct
Above is my Table and find below the required result.Similarly for other regions as well. Can anyone help me with the SQL Query?
Region
Resolution Summary
Adjustment
Credit Memo
Invoice
Grand Total
AMERICAS
Correct
1
1
2
Incorrect
0
1
1
2Like this?
SQL> select * from transaction_audit;
REGION MTH TRX_TYPE RESOLUTIO
AMERICAS may-13 ADJUSTMENTS CORRECT
EMEA may-13 ADJUSTMENTS INCORRECT
AMERICAS may-13 CREDIT MEMO INCORRECT
EMEA may-13 INVOICE CORRECT
AMERICAS may-13 CREDIT MEMO CORRECT
OFD may-13 ADJUSTMENTS CORRECT
AMERICAS may-13 INVOICE INCORRECT
LAD may-13 ADJUSTMENTS CORRECT
LAD may-13 ADJUSTMENTS CORRECT
OFD may-13 ADJUSTMENTS CORRECT
10 rows selected.
SQL> select region
2 , resolution_summary
3 , count(decode(trx_type, 'ADJUSTMENTS', trx_type)) adjustments
4 , count(decode(trx_type, 'CREDIT MEMO', trx_type)) credit_memo
5 , count(decode(trx_type, 'INVOICE' , trx_type)) invoice
6 from transaction_audit
7 group
8 by region
9 , resolution_summary
10 order
11 by region
12 , resolution_summary
13 /
REGION RESOLUTIO ADJUSTMENTS CREDIT_MEMO INVOICE
AMERICAS CORRECT 1 1 0
AMERICAS INCORRECT 0 1 1
EMEA CORRECT 0 0 1
EMEA INCORRECT 1 0 0
LAD CORRECT 2 0 0
OFD CORRECT 2 0 0
6 rows selected.
SQL> -
Need sql query to solve the problem?
Hi,
My table contains data which is mentioned below:
Region
Country
DeviceType
Brand
ModelExt
AttributeGroup
AttributeType
AttributeValue
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input Key name on control panel_key order
Asdfg.1.1
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input Key name on control panel_key order
Input.TV
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
ASDFG.1.in
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
Input.Tv.IN
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input key Name on Display_key Order
RTYU.1
And i need O/p like
Region
Country
DeviceType
Brand
ModelExt
AttributeGroup
Input Key name on control panel_key order
Input key Name on Display_key Order
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Asdfg.1.1
ASDFG.1.in
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
Input.TV
Input.Tv.IN
NULL
NULL
A/V Receiver
Sony
STRD560Z
Input keys order
RTYU.1
Please help. Req. is urgent.
Regards,
PuneethYou can use the CASE expression to pivot the AttributeType column.
Examples for CASE expression usage:
http://www.sqlusa.com/bestpractices/training/scripts/casefunction/
A second possibility is the PIVOT operator:
http://technet.microsoft.com/en-us/library/ms177410(v=sql.105).aspx
Instead of the COUNT or SUM operators, use MIN or MAX operators.
Kalman Toth Database & OLAP Architect
SQL Server 2014 Database Design
New Book / Kindle: Beginner Database Design & SQL Programming Using Microsoft SQL Server 2014 -
Hierarchy: How to suppress duplicated/repeated rows in a BEx query
Hi Gurus.
I have a BEx query which displays data based on a Cost Element hierarchy. When the hierarchy is expanded to leaf level (or any level), all key figures and characteristics are displayed for the leaf level but are also repeated throughout all the levels above.
Is it possible to suppress the repeated rows in higher levels of the hierarchy and display a summary result only?
The issue we have is that if the user wishes to export or save a workbook, they will have to filter and manipulate the report a great deal which is impractical.
I'm hoping it's a simple setting that I've missed. I look forward to receiving the magic answer!! :o)
Thanks,
AngelaHi All,
I've been playing around a bit more and found a setting which I hope my users will find acceptable:
From the query - Query properties -> Data Formatting tab - Multidimensional View -> select Display Rows hierarchically and expand to (chosen characteristic)
Can anyone tell me if I can set this as a default setting in the query designer, or will I need to create a view to save the setting?
Thanks all,
Angela -
Sql query to indetify the identical data
Hi
I would like to know the query to identify the identical data in same table.
Example: I have table called 'AA" having same data for load_ctry i.e. 'MY' and 'HK' ,I need sql query to indetify the identical data for above countries in that table.
Thanks
MRHi,
Table called "AA" with columns col1,col2,col3,load_ctry with following sample date
col1 col2 col3 load_ctry
3 bg xx TH
4 op xc TH
3 bg xx MY
4 op xc MY
3 vb nb MY
When query ,if data is identical for both countries ,no data to fecth or data identical .If data is differ ,it will return the mismatching data becuase we are using same table for both countries .
Thanks
MR -
Sql Query : Sum , all the possible combination of rows in a table
SQL Server 2008 R2
Sample Table structure
create table TempTable
ID int identity,
value int
insert into TempTable values(6)
insert into TempTable values(7)
insert into TempTable values(8)
insert into TempTable values(9)
insert into TempTable values(10)
I actually want something like below,
that It returns rows such that, it has the sum of all the remaining rows , as shown below.
I will ignore the repeated rows.
6+7
6+8
6+9
6+10
6+7+8
6+7+9
6+7+10
6+8+9
6+8+10
6+9+10
6+7+8+9
6+7+8+9+10This makes no sense. What about NULLs? What about duplicate values? You have rows, so you have many combinations. We know that this set totals to 39, so there is no subset totals to half of any odd number. 19.5
in this case.
None of your examples are
even close!
6+7 = 13
the remaining rows 8+9+10 = 27, so you failed!
Want to try again?
--CELKO-- Books in Celko Series for Morgan-Kaufmann Publishing: Analytics and OLAP in SQL / Data and Databases: Concepts in Practice Data / Measurements and Standards in SQL SQL for Smarties / SQL Programming Style / SQL Puzzles and Answers / Thinking
in Sets / Trees and Hierarchies in SQL -
SQL query that returns exclusive rows from groups
I'm using modified scott/tiger data for this.
I've got two tables
DEPT_X
DEPTNO DNAME LOC CODE_ID SUB_DEPTNO
10 ACCOUNTING NEW YORK 111 101
10 SALES ATWN 111 102
10 SALES BTWN 112 103
20 RESEARCH DALLAS 111 201
20 RESEARCH CTWN 111 202
30 SALES CHICAGO 111 301
40 OPERATIONS BOSTON 112 401and
BI_PD
CODE_ID PD_TYPE BI_TYPE
111 -1
112 -1 I want to write a query that joins the code_ids of the two tables and lists out either only the records from DEPT_X who's code_ids have a -1 in the PD_TYPE(112) column and none of the code_ids that have a -1 in the BI_TYPE(111) column for each department or if that department has code_ids for the BI_TYPE (111), list out those rows. So for Deptno 10 you'll only get the row with SUB_DEPTNO = 103. But if for that DEPTNO= 20 you'll get the rows for both SUB_DEPTNO = 201 and 202.
So the result should look like
DEPTNO SUB_DEPTNO
10 103
20 201
20 202
30 301.
Basically I just want rows from each department that have code_ids = 111 not to show up if there are code_ids = 112.
What is the query to do this?
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359
Message was edited by:
user623359One way could be:
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
With the Partitioning, OLAP and Data Mining options
SQL> with dept_x as (
2 select 10 deptno, 'ACCOUNTING' dname, 'NEW YORK' loc, 111 code_id, 101 sub_deptno from dual
union all
3 select 10, 'SALES', 'ATWN', 111, 102 from dual union all
4 select 10, 'SALES', 'BTWN', 112, 103 from dual union all
5 select 20, 'RESEARCH', 'DALLAS', 111, 201 from dual union all
6 select 20, 'RESEARCH', 'CTWN', 111, 202 from dual union all
7 select 30, 'SALES', 'CHICAGO', 111, 301 from dual union all
8 select 40, 'OPERATIONS', 'BOSTON', 112, 401 from dual ),
9 --
10 bi_pd as(
11 select 111 code_id, null pd_type, -1 bi_type from dual union all
12 select 112, -1, null from dual),
13 --
14 t as(
15 select a.deptno,a.sub_deptno from dept_x a, bi_pd b
16 where a.code_id = b.code_id and b.pd_type = -1)
17 --
18 select a.deptno,a.sub_deptno
19 from dept_x a, bi_pd b
20 where a.code_id = b.code_id and b.bi_type = -1 and
21 (a.deptno) not in (select deptno from t)
22 union
23 select deptno,sub_deptno from t;
DEPTNO SUB_DEPTNO
10 103
20 201
20 202
30 301
40 401 -
Hi
I am trying to wright a SQL query that will return the date the timesheet was submitted and date/time it was approved, can anyone guide me on this?
I basically need person name who submitted, date - time it was submitted for approval, then the person who approved it and the date - time that it was approved
Thanks
RubyRuby,
you can start with HXC_TIMECARD_SUMMARY table for submitter detail. But for approver details, i think you need WF tables to get the data for item type HXCEMP. -
Reg: sql query that prints all sundays in the year
Hi all,
Please give me sql query that prints all sundays in year. And when ever we execute that query then that will prints the sysdate(that is execution date).
Thanks in Advance,
-prasad.
Edited by: prasad_orcl on Jun 5, 2009 9:13 PMHi,
Plz try this and let me know this works or not...
SELECT DATE DATES,TO_CHAR(DATE,'DAY') DAYS FROM FISCAL_CALENDAR
WHERE DATE_YEAR = 2009 AND
DATE BETWEEN TRUNC(SYSDATE,'YEAR') AND
ADD_MONTHS(TRUNC(SYSDATE,'YEAR'),12) -1 AND
TRIM(TO_CHAR(DATE,'DAY')) = 'SUNDAY'
ORDER BY DATE
OUTPUT:
DATES DAYS
1/4/2009 SUNDAY
1/11/2009 SUNDAY
1/18/2009 SUNDAY
1/25/2009 SUNDAY
2/1/2009 SUNDAY
2/8/2009 SUNDAY
2/15/2009 SUNDAY
2/22/2009 SUNDAY
3/1/2009 SUNDAY
3/8/2009 SUNDAY
3/15/2009 SUNDAY
3/22/2009 SUNDAY
3/29/2009 SUNDAY
4/5/2009 SUNDAY
4/12/2009 SUNDAY
4/19/2009 SUNDAY
4/26/2009 SUNDAY
5/3/2009 SUNDAY
5/10/2009 SUNDAY
5/17/2009 SUNDAY
5/24/2009 SUNDAY
5/31/2009 SUNDAY
6/7/2009 SUNDAY
6/14/2009 SUNDAY
6/21/2009 SUNDAY
6/28/2009 SUNDAY
7/5/2009 SUNDAY
7/12/2009 SUNDAY
7/19/2009 SUNDAY
7/26/2009 SUNDAY
8/2/2009 SUNDAY
8/9/2009 SUNDAY
8/16/2009 SUNDAY
8/23/2009 SUNDAY
8/30/2009 SUNDAY
9/6/2009 SUNDAY
9/13/2009 SUNDAY
9/20/2009 SUNDAY
9/27/2009 SUNDAY
10/4/2009 SUNDAY
10/11/2009SUNDAY
10/18/2009SUNDAY
10/25/2009SUNDAY
11/1/2009 SUNDAY
11/8/2009 SUNDAY
11/15/2009SUNDAY
11/22/2009SUNDAY
11/29/2009SUNDAY
12/6/2009 SUNDAY
12/13/2009SUNDAY
12/20/2009SUNDAY
12/27/2009SUNDAY
Regards
Thiyag -
Custom PL/SQL API that inserts the data into a custom interface table.
We are developing a custom Web ADI integrator for importing suppliers into Oracle.
The Web ADI interface is a custom PL/SQL API that inserts the data into a custom interface table. We have defined the content, uploader and an importer. The importer is again a custom PL/SQL API that will process the records inserted into the custom table and updates the STATUS column of the custom interface table. We want to show the status column back on the spreadsheet.
Defined the 'Document Row' import rule and added the rows that would identify the unique record.
Errored row import rule, we are using a SELECT * from custom_table where status<>'Success' and vendor_name=$param$.vendor_name
The source of this parameter is import.vendor_name
We have also defined an Error lookup.
After the above setup is completed, we invoke the create document and click on Oracle->Upload.
The records are getting imported, but the importer program is failing with An error has occurred while running an API import. The ERRORED_ROWS step 20003:ER_500141, parameter number 1 must contain the value BIND in attribute 1.'The same issue.
Need help.
Also checked bne.log, no additional information.
<bne:document xmlns:bne="http://www.oracle.com/bne">
<bne:message bne:type="DATA" bne:text="BNE_VALID_ROW_COUNT" bne:value="11" />
<bne:message bne:type="DATA" bne:text="BNE_INVALID_ROW_COUNT" bne:value="0" />
<bne:message bne:type="ERROR" bne:text="An error has occurred while running an API import"
bne:cause="The ERRORED_ROWS step 20003:ER_500165, parameter number 1 must contain the value BIND in attribute 1."
bne:action="" bne:source="BneAPIImporter" >
<bne:context bne:collection="collection_1" />
</bne:message><bne:message bne:type="STATUS"
bne:text="No rows uploaded" bne:value="" >
<bne:context bne:collection="collection_1" /></bne:message>
<bne:message bne:type="STATUS" bne:text="0 rows were invalid" bne:value="" >
<bne:context bne:collection="collection_1" /></bne:message></bne:document> -
PL SQL Grouping and Edit the Oldest Row in a Group
Event Table
CREATE TABLE "EVENT" ("EVENT_ID" VARCHAR2(36), "EVENTTYPE" VARCHAR2(110), "WHEN_OCCURRED" TIMESTAMP (6),"DESCRIPTION" VARCHAR2(255), "CURRENCY" VARCHAR2(3), "AMOUNT" NUMBER(38,8), "TRANSACTION_ID" VARCHAR2(255) )
Insert into EVENT (EVENT_ID,EVENTTYPE,DESCRIPTION,CURRENCY,AMOUNT,TRANSACTION_ID) values ('1','paymentEvent',to_timestamp('15-AUG-11 10.11.30.165000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'Payment Transaction Confirmed','USD',10','3');
Insert into EVENT (EVENT_ID,EVENTTYPE,DESCRIPTION,CURRENCY,AMOUNT,TRANSACTION_ID) values ('2','paymentEvent',to_timestamp('15-AUG-11 12.31.23.162000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'Payment Transaction Confirmed','USD',10,'3085c51d-6425-4974-b2fb-f5bdc4d08137');
Transaction table
CREATE TABLE "TRANSACTION" ("TRANSACTION_ID" VARCHAR2(36 BYTE), "LAST_UPDATED" TIMESTAMP (6), "DESCRIPTION" VARCHAR2(255 BYTE), "TYPE" VARCHAR2(255 BYTE), "DEBIT_CREDIT" NUMBER(38,8), "ORIGINAL_ID" VARCHAR2(36 BYTE), "TYPE" VARCHAR2(255 BYTE))
Insert into TRANSACTION (TRANSACTION_ID,LAST_UPDATED,DESCRIPTION,TYPE,DEBIT_CREDIT,ORIGINAL_ID,EVENT_ID) values ('c8ef1e7c-4134-45d8-9568-5da2fc41e137',to_timestamp('15-AUG-11 12.01.42.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'Correction: Payment Transaction Confirmed','SETTLEMENT',1,'3','1', 'debit');
Insert into TRANSACTION (TRANSACTION_ID,LAST_UPDATED,DESCRIPTION,TYPE,DEBIT_CREDIT,ORIGINAL_ID,EVENT_ID) values ('8243cc1d-614d-4cfd-9c3b-b5cd44b3a67f',to_timestamp('15-AUG-11 12.29.45.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'Correction: Payment Transaction Confirmed','SETTLEMENT',1,'3','1', 'credit');
Insert into TRANSACTION (TRANSACTION_ID,LAST_UPDATED,DESCRIPTION,TYPE,DEBIT_CREDIT,ORIGINAL_ID,EVENT_ID) values ('3',to_timestamp('15-AUG-11 10.11.30.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'testCharge','PAYMENT',10,null,null,null);
Insert into TRANSACTION (TRANSACTION_ID,LAST_UPDATED,DESCRIPTION,TYPE,DEBIT_CREDIT,ORIGINAL_ID,EVENT_ID) values ('609f264b-1cef-4615-8f28-d8dae391dbba',to_timestamp('15-AUG-11 10.17.43.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'Correction: Payment Transaction Confirmed','SETTLEMENT',4,'3','1', 'debit');
Insert into TRANSACTION (TRANSACTION_ID,LAST_UPDATED,DESCRIPTION,TYPE,DEBIT_CREDIT,ORIGINAL_ID,EVENT_ID) values ('3085c51d-6425-4974-b2fb-f5bdc4d08137',to_timestamp('15-AUG-11 12.31.23.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'testCharge','PAYMENT',10,null,null,null);
Insert into TRANSACTION (TRANSACTION_ID,LAST_UPDATED,DESCRIPTION,TYPE,DEBIT_CREDIT,ORIGINAL_ID,EVENT_ID) values ('bafc4f83-d3b7-45f2-b35d-ba4101eebf3c',to_timestamp('15-AUG-11 12.31.44.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),Settle: Payment Transaction Confirmed','SETTLEMENT',2,'3085c51d-6425-4974-b2fb-f5bdc4d08137','2','debit');
Insert into TRANSACTION (TRANSACTION_ID,LAST_UPDATED,DESCRIPTION,TYPE,DEBIT_CREDIT,ORIGINAL_ID,EVENT_ID) values ('bbb6123b-8b70-45f2-b593-5b6bb2afd6b2',to_timestamp('15-AUG-11 10.18.56.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'Correction: Payment Transaction Confirmed','SETTLEMENT',2,'3','1','credit');
Result
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,TRX_DESC,GROSS,NET) values ('609f264b-1cef-4615-8f28-d8dae391dbba',to_timestamp('15-AUG-11 10.17.43.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),0,4,'3','Payment Transaction Confirmed',10,6);
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,TRX_DESC,GROSS,NET) values ('bbb6123b-8b70-45f2-b593-5b6bb2afd6b2',to_timestamp('15-AUG-11 10.18.56.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),2,0,'3','Correction: Payment Transaction Confirmed',0,2);
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,TRX_DESC,GROSS,NET) values ('c8ef1e7c-4134-45d8-9568-5da2fc41e137',to_timestamp('15-AUG-11 12.01.42.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),0,1,'3','Correction: Payment Transaction Confirmed'0,-1);
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,TRX_DESC,GROSS,NET) values ('8243cc1d-614d-4cfd-9c3b-b5cd44b3a67f',to_timestamp('15-AUG-11 12.29.45.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),1,0,'3','Correction: Payment Transaction Confirmed'0,1);
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,TRX_DESC,GROSS,NET) values ('bafc4f83-d3b7-45f2-b35d-ba4101eebf3c',to_timestamp('15-AUG-11 12.31.44.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),0,2,'3085c51d-6425-4974-b2fb-f5bdc4d08137','Payment Transaction Confirmed'10,8);
Explanation
* Each event table insert has a respective type='payment' insert in transaction table.
* My result interesting only about transaction type='settlement'
* One type = 'payment' transaction could have one type = 'settlement' by default. But in a some cases (an error) there be many type = settlement
* When we take transaction_id = '3' it has 4 'settlement' transactions
To the result these four(4) settlement takes and out of a four the oldest transaction should have a different presentation
(See result number 01)
If payment transaction has only one settlement transaction then the result description = Payment Transaction Confirmed
gross = respective event table amount
net = gross + credit - debit
if payment transaction has more than one settlement transaction then * Oldest transaction ( order by LAST_UPDATED)
description = Payment Transaction Confirmed
gross = respective event table amount
net = gross + credit - debit
* All other transactions
description = Correction: Payment Transaction Confirmed
gross = 0
net = if type = debit then net = -(debit) else credit
Appreciate your help for write a PL/SQL query that satisfies above.
I am thinking to
Group all relative settlement transactions into one unit.
Find oldest among them
Apply different logic for oldest
Apply common logic for othersStill need some help from you guys to convert my thoughts into SQL
ThanksYes. that is what I initially trying to do. But no success.
Please refer below my effort
Transaction table
CREATE TABLE "TRANSACTION" ("TRANSACTION_ID" VARCHAR2(36 BYTE), "OBJECT_TYPE" VARCHAR2(255 BYTE), "VERSION" NUMBER(19,0), "CREATED" TIMESTAMP (6), "LAST_UPDATED" TIMESTAMP (6), "DESCRIPTION" VARCHAR2(255 BYTE), "EXTERNAL_ID" VARCHAR2(255 BYTE), "TYPE" VARCHAR2(255 BYTE), "STATE" VARCHAR2(255 BYTE), "LAST_STATE_CHANGE" TIMESTAMP (6), "CHANNEL" VARCHAR2(255 BYTE), "MANDATE_ID" VARCHAR2(255 BYTE), "SUBSCRIPTION_ID" VARCHAR2(255 BYTE), "BULK_REFUND_TASK_ID" VARCHAR2(255 BYTE), "GROSS_CURRENCY" VARCHAR2(3 BYTE), "GROSS_AMOUNT" NUMBER(38,8), "TAX_CURRENCY" VARCHAR2(3 BYTE), "TAX_AMOUNT" NUMBER(38,8), "PAYER_ID" VARCHAR2(36 BYTE), "PAYEE_ID" VARCHAR2(36 BYTE), "ON_BEHALF_OF_PAYEE" VARCHAR2(255 BYTE), "ORIGINAL_ID" VARCHAR2(36 BYTE), "TRANSFER_ID" VARCHAR2(36 BYTE), "EVENT_ID" VARCHAR2(36 BYTE), "TERM_ID" VARCHAR2(36 BYTE), "CHARGE" NUMBER(1,0) DEFAULT 0, "TAGS_AND_VALUES" VARCHAR2(4000 BYTE), "LARGE_TAGS_AND_VALUES" CLOB, "EXPORT_PENDING" VARCHAR2(4 BYTE) DEFAULT 'TRUE')
Data
Insert into TRANSACTION (TRANSACTION_ID,OBJECT_TYPE,VERSION,CREATED,LAST_UPDATED,DESCRIPTION,EXTERNAL_ID,TYPE,STATE,LAST_STATE_CHANGE,CHANNEL,MANDATE_ID,SUBSCRIPTION_ID,BULK_REFUND_TASK_ID,GROSS_CURRENCY,GROSS_AMOUNT,TAX_CURRENCY,TAX_AMOUNT,PAYER_ID,PAYEE_ID,ON_BEHALF_OF_PAYEE,ORIGINAL_ID,TRANSFER_ID,EVENT_ID,TERM_ID,CHARGE,TAGS_AND_VALUES,EXPORT_PENDING) values ('c8ef1e7c-4134-45d8-9568-5da2fc41e137','com.valista.trxe.model.Transaction',1,to_timestamp('15-AUG-11 12.01.42.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('15-AUG-11 12.01.42.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'Correction: Payment Transaction Confirmed',null,'SETTLEMENT','CONFIRMED',to_timestamp('15-AUG-11 12.01.42.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),null,null,null,null,'USD',1,'USD',0,'9f285bf7-46a1-4621-b165-dc782bf1d1ae','1c887a16-4344-4a80-8a11-f26d80824e4a',null,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14','f24be53d-7b78-455c-b1ac-f9fc242ec5ff','a2f09cbb-1555-4c8d-b401-0233982cfa7e','c6b70c01-7f9a-4d96-93a6-e8e1b568cf59',1,null,'TRUE');
Insert into TRANSACTION (TRANSACTION_ID,OBJECT_TYPE,VERSION,CREATED,LAST_UPDATED,DESCRIPTION,EXTERNAL_ID,TYPE,STATE,LAST_STATE_CHANGE,CHANNEL,MANDATE_ID,SUBSCRIPTION_ID,BULK_REFUND_TASK_ID,GROSS_CURRENCY,GROSS_AMOUNT,TAX_CURRENCY,TAX_AMOUNT,PAYER_ID,PAYEE_ID,ON_BEHALF_OF_PAYEE,ORIGINAL_ID,TRANSFER_ID,EVENT_ID,TERM_ID,CHARGE,TAGS_AND_VALUES,EXPORT_PENDING) values ('8243cc1d-614d-4cfd-9c3b-b5cd44b3a67f','com.valista.trxe.model.Transaction',1,to_timestamp('15-AUG-11 12.29.45.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('15-AUG-11 12.29.45.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'Correction: Payment Transaction Confirmed',null,'SETTLEMENT','CONFIRMED',to_timestamp('15-AUG-11 12.29.45.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),null,null,null,null,'USD',1,'USD',0,'1c887a16-4344-4a80-8a11-f26d80824e4a','9f285bf7-46a1-4621-b165-dc782bf1d1ae',null,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14','ac5ae000-7ca8-4542-bf83-8d99e085e706','a2f09cbb-1555-4c8d-b401-0233982cfa7e','b70382c8-a05e-49c4-9919-ad765c5c5046',1,null,'TRUE');
Insert into TRANSACTION (TRANSACTION_ID,OBJECT_TYPE,VERSION,CREATED,LAST_UPDATED,DESCRIPTION,EXTERNAL_ID,TYPE,STATE,LAST_STATE_CHANGE,CHANNEL,MANDATE_ID,SUBSCRIPTION_ID,BULK_REFUND_TASK_ID,GROSS_CURRENCY,GROSS_AMOUNT,TAX_CURRENCY,TAX_AMOUNT,PAYER_ID,PAYEE_ID,ON_BEHALF_OF_PAYEE,ORIGINAL_ID,TRANSFER_ID,EVENT_ID,TERM_ID,CHARGE,TAGS_AND_VALUES,EXPORT_PENDING) values ('61db88ec-ade8-4cc3-90f3-e49fa26dcf14','com.valista.trxe.model.Transaction',5,to_timestamp('15-AUG-11 10.11.30.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('15-AUG-11 12.29.45.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'testCharge',null,'PAYMENT','CONFIRMED',to_timestamp('15-AUG-11 10.11.30.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),null,null,null,null,'USD',10,'USD',0,'e8a58763-9faa-4632-a2b3-747aa00fe9c4','9f285bf7-46a1-4621-b165-dc782bf1d1ae',null,null,'ac45ebc4-f817-42e7-8d4a-96e41fb40ef8',null,null,1,null,'TRUE');
Insert into TRANSACTION (TRANSACTION_ID,OBJECT_TYPE,VERSION,CREATED,LAST_UPDATED,DESCRIPTION,EXTERNAL_ID,TYPE,STATE,LAST_STATE_CHANGE,CHANNEL,MANDATE_ID,SUBSCRIPTION_ID,BULK_REFUND_TASK_ID,GROSS_CURRENCY,GROSS_AMOUNT,TAX_CURRENCY,TAX_AMOUNT,PAYER_ID,PAYEE_ID,ON_BEHALF_OF_PAYEE,ORIGINAL_ID,TRANSFER_ID,EVENT_ID,TERM_ID,CHARGE,TAGS_AND_VALUES,EXPORT_PENDING) values ('609f264b-1cef-4615-8f28-d8dae391dbba','com.valista.trxe.model.Transaction',1,to_timestamp('15-AUG-11 10.17.43.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('15-AUG-11 10.17.43.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'Correction: Payment Transaction Confirmed',null,'SETTLEMENT','CONFIRMED',to_timestamp('15-AUG-11 10.17.43.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),null,null,null,null,'USD',4,'USD',0,'9f285bf7-46a1-4621-b165-dc782bf1d1ae','1c887a16-4344-4a80-8a11-f26d80824e4a',null,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14','c0e866f2-0389-4fe3-9b11-f9ed6f49dd66','a2f09cbb-1555-4c8d-b401-0233982cfa7e','64103b9f-b760-4add-8c43-dbc7ac501fda',1,null,'TRUE');
Insert into TRANSACTION (TRANSACTION_ID,OBJECT_TYPE,VERSION,CREATED,LAST_UPDATED,DESCRIPTION,EXTERNAL_ID,TYPE,STATE,LAST_STATE_CHANGE,CHANNEL,MANDATE_ID,SUBSCRIPTION_ID,BULK_REFUND_TASK_ID,GROSS_CURRENCY,GROSS_AMOUNT,TAX_CURRENCY,TAX_AMOUNT,PAYER_ID,PAYEE_ID,ON_BEHALF_OF_PAYEE,ORIGINAL_ID,TRANSFER_ID,EVENT_ID,TERM_ID,CHARGE,TAGS_AND_VALUES,EXPORT_PENDING) values ('3085c51d-6425-4974-b2fb-f5bdc4d08137','com.valista.trxe.model.Transaction',2,to_timestamp('15-AUG-11 12.31.23.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('15-AUG-11 12.31.44.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'testCharge',null,'PAYMENT','CONFIRMED',to_timestamp('15-AUG-11 12.31.23.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),null,null,null,null,'USD',10,'USD',0,'e8a58763-9faa-4632-a2b3-747aa00fe9c4','9f285bf7-46a1-4621-b165-dc782bf1d1ae',null,null,'db78d04e-c23d-4601-9b0e-76e826e85e29',null,null,1,null,'TRUE');
Insert into TRANSACTION (TRANSACTION_ID,OBJECT_TYPE,VERSION,CREATED,LAST_UPDATED,DESCRIPTION,EXTERNAL_ID,TYPE,STATE,LAST_STATE_CHANGE,CHANNEL,MANDATE_ID,SUBSCRIPTION_ID,BULK_REFUND_TASK_ID,GROSS_CURRENCY,GROSS_AMOUNT,TAX_CURRENCY,TAX_AMOUNT,PAYER_ID,PAYEE_ID,ON_BEHALF_OF_PAYEE,ORIGINAL_ID,TRANSFER_ID,EVENT_ID,TERM_ID,CHARGE,TAGS_AND_VALUES,EXPORT_PENDING) values ('bafc4f83-d3b7-45f2-b35d-ba4101eebf3c','com.valista.trxe.model.Transaction',1,to_timestamp('15-AUG-11 12.31.44.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('15-AUG-11 12.31.44.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),'Settle: Payment Transaction Confirmed',null,'SETTLEMENT','CONFIRMED',to_timestamp('15-AUG-11 12.31.44.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),null,null,null,null,'USD',2,'USD',0,'9f285bf7-46a1-4621-b165-dc782bf1d1ae','1c887a16-4344-4a80-8a11-f26d80824e4a',null,'3085c51d-6425-4974-b2fb-f5bdc4d08137','9b5e384c-7ce9-4d7a-871e-5f418e737205','9c5cb90a-2035-490f-9ca7-c70f24a9010c','b70382c8-a05e-49c4-9919-ad765c5c5046',1,null,'TRUE');
Insert into TRANSACTION (TRANSACTION_ID,OBJECT_TYPE,VERSION,CREATED,LAST_UPDATED,DESCRIPTION,EXTERNAL_ID,TYPE,STATE,LAST_STATE_CHANGE,CHANNEL,MANDATE_ID,SUBSCRIPTION_ID,BULK_REFUND_TASK_ID,GROSS_CURRENCY,GROSS_AMOUNT,TAX_CURRENCY,TAX_AMOUNT,PAYER_ID,PAYEE_ID,ON_BEHALF_OF_PAYEE,ORIGINAL_ID,TRANSFER_ID,EVENT_ID,TERM_ID,CHARGE,TAGS_AND_VALUES,EXPORT_PENDING) values ('bbb6123b-8b70-45f2-b593-5b6bb2afd6b2','com.valista.trxe.model.Transaction',1,to_timestamp('15-AUG-11 10.18.56.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),to_timestamp('15-AUG-11 10.18.56.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),'Correction: Payment Transaction Confirmed',null,'SETTLEMENT','CONFIRMED',to_timestamp('15-AUG-11 10.18.56.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),null,null,null,null,'USD',2,'USD',0,'1c887a16-4344-4a80-8a11-f26d80824e4a','9f285bf7-46a1-4621-b165-dc782bf1d1ae',null,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14','bef6cea1-d188-44e6-a5cf-6282480e13c2','a2f09cbb-1555-4c8d-b401-0233982cfa7e','e4a0bb0b-7273-4f28-8681-04fc067cb80d',1,null,'TRUE');
My Query
select transaction_id as trx_id,
last_updated,
nvl((case when payee_id= '9f285bf7-46a1-4621-b165-dc782bf1d1ae' then gross_amount end),0) as credit,
nvl((case when payer_id= '9f285bf7-46a1-4621-b165-dc782bf1d1ae' then gross_amount end),0) as debit,
connect_by_root transaction_id root,
rownum rn,
description as trx_desc
from (select * from transaction order by last_updated )
where type = 'SETTLEMENT'
start with original_id is null
connect by original_id = prior transaction_id order by last_updated
Result I got ( this is not a table just result set )
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('609f264b-1cef-4615-8f28-d8dae391dbba',to_timestamp('15-AUG-11 10.17.43.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),0,4,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14',1,'Correction: Payment Transaction Confirmed');
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('bbb6123b-8b70-45f2-b593-5b6bb2afd6b2',to_timestamp('15-AUG-11 10.18.56.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),2,0,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14',2,'Correction: Payment Transaction Confirmed');
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('c8ef1e7c-4134-45d8-9568-5da2fc41e137',to_timestamp('15-AUG-11 12.01.42.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),0,1,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14',3,'Correction: Payment Transaction Confirmed');
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('8243cc1d-614d-4cfd-9c3b-b5cd44b3a67f',to_timestamp('15-AUG-11 12.29.45.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),1,0,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14',4,'Correction: Payment Transaction Confirmed');
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('bafc4f83-d3b7-45f2-b35d-ba4101eebf3c',to_timestamp('15-AUG-11 12.31.44.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),0,2,'3085c51d-6425-4974-b2fb-f5bdc4d08137',5,'Settle: Payment Transaction Confirmed');
Result I want to get
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('609f264b-1cef-4615-8f28-d8dae391dbba',to_timestamp('15-AUG-11 10.17.43.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),0,4,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14',1,'Correction: Payment Transaction Confirmed');
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('bbb6123b-8b70-45f2-b593-5b6bb2afd6b2',to_timestamp('15-AUG-11 10.18.56.000000000 AM','DD-MON-RR HH.MI.SS.FF AM'),2,0,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14',2,'Correction: Payment Transaction Confirmed');
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('c8ef1e7c-4134-45d8-9568-5da2fc41e137',to_timestamp('15-AUG-11 12.01.42.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),0,1,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14',3,'Correction: Payment Transaction Confirmed');
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('8243cc1d-614d-4cfd-9c3b-b5cd44b3a67f',to_timestamp('15-AUG-11 12.29.45.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),1,0,'61db88ec-ade8-4cc3-90f3-e49fa26dcf14',4,'Correction: Payment Transaction Confirmed');
Insert into EXPORT_TABLE (TRX_ID,LAST_UPDATED,CREDIT,DEBIT,ROOT,RN,TRX_DESC) values ('bafc4f83-d3b7-45f2-b35d-ba4101eebf3c',to_timestamp('15-AUG-11 12.31.44.000000000 PM','DD-MON-RR HH.MI.SS.FF AM'),0,2,'3085c51d-6425-4974-b2fb-f5bdc4d08137',1,'Settle: Payment Transaction Confirmed');
Explanation
Refer 5th record of the result set. It has a RN = 5 and I want to get RN = 1 for that since that has a different ROOT and since it's the oldest memeber.
So Iwant to get RN as
date root row_number or something just find the oldest memeber in a tree
15-AUG-11 10.17.43.000000000 AM 61db88ec-ade8-4cc3-90f3-e49fa26dcf14 1
15-AUG-11 10.18.56.000000000 AM 61db88ec-ade8-4cc3-90f3-e49fa26dcf14 2
15-AUG-11 12.01.42.000000000 PM 61db88ec-ade8-4cc3-90f3-e49fa26dcf14 3
15-AUG-11 10.25.56.000000000 AM 55db88ec-ade8-4cc3-90f3-e49fa26dcf14 1
15-AUG-11 10.27.56.000000000 AM 55db88ec-ade8-4cc3-90f3-e49fa26dcf14 2
15-AUG-11 10.55.56.000000000 AM 85db88ec-ade8-4cc3-90f3-e49fa26dcf14 1 -
Dear All,
I have a requirement, to write a SQL query to populate the records which are inserted less than 10 no of records.
The tables has the cretaed_date column and along with other key column which will have unique values.
Ex1: The user might have inserted records from application, per week basis, between the date range '01-jun-2013' - 08-jun-2013 , the no of records created by the user during this week may be less than 10 records or more.
But I want to populate the records by giving date range that too, it should pick the records the count which fall with in 10 records.
I dont want the query to populate the records if the user has inserted more than 10 records in a week.
Ex2:
User 1 has created 15 records during the week 1 ( the query should not populate this ).
User 2: has cretaed less than 10 records from the UI during the week 2. ( This details should get populated ).
ThanksUse COUNT to find how many rows where inserted in a week.
If this does not answer your question then please read Re: 2. How do I ask a question on the forums? And provide necessary details. -
SQL query to get the list of approvals
Hi,
Could someone let me know the SQL query to get the list of all the pending approvals for a user in OIM 11g R2.
ThanksThere are a few ways to do this:
- The easiest would be to use a Relationship Query from the CMC. To do this, go to the Universes section on the CMC, right click on the relevant universe, select tools >> Check Relationships.
- Use Query Builder. You will need more than one query to pull the information you need. You could try something like the below (for Webi)
SELECT SI_NAME, SI_WEBI, SI_DATACONNECTION FROM CI_APPOBJECTS
WHERE SI_KIND = 'universe' and SI_NAME = 'Universe Name'
This will give you a list of Webi Reports by SI_ID.
You'll need another query to list Webi report names:
SELECT SI_NAME FROM CI_INFOOBJECTS WHERE SI_ID IN (SI_ID from query above)
- This is trivial via Auditing / the Activity universe. This of course will only return reports that have already run.
Best.
Srinivas
Maybe you are looking for
-
Bought a new imac itunes wont transfer my tv show to my iPhone 4
A few months ago i bought and new i mac and have been unable to transfer my tv shows bought on itunes to my iphone 4 help me???
-
I currently have OS X version 10.5.8 what is my next upgrade?
I currently have Mac OS X version 10.5.8 - intel processor what should my next upgrade be? I need to upgrade in order to accommodate my new ipod nano.
-
Need help pl/sql function body returning SQL query - Reports
I need help with Grouping by on a report that I developed in my application. I have posted my Code in Apex.oracle.com workspace : c a s e _ m a n a g e m e n t User Id : public Password : public I need help on Page 38 Reports. I get blank lines when
-
Forms going read-only in Workbench
Has anyone else had a problem with forms going read-only unexpectedly in Workbench ES? With no one else logged-in to the server, I'm experiencing intermittent errors where the current form I am working on suddenly thinks it is a read-only document an
-
Q5 Calendar doesn't keep appointments that aren't recurring.
So about a week ago my wife and I upgraded to Q5's. Immediately my wife went to entering all of our schedule info into her calendar and invited me to each appointment. It is our way of making sure who working / family task. etc..etc.etc.. However ALL