Query to group records
hi,
i have records like this
supplier,product, persons involved
10,150,[email protected]
30,200,[email protected]
20,111,[email protected]
40,211,[email protected]
i want to write a query which displays values like this
10,30,40,[email protected]
for [email protected] if there are n number of suppliers all need to be concatenated as shown above.
can any one help me on this
Its a Typical String Aggregation Question.
[String Aggregation Techniques|http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php] might be an interesting read for you.
SQL> With Test_Tab as
2 (
3 SELECT 10 supplier,150 product, '[email protected]' persons_involved FROM Dual
4 UNION ALL
5 SELECT 30,200,'[email protected]' FROM Dual
6 UNION ALL
7 SELECT 20,111,'[email protected]' FROM Dual
8 UNION ALL
9 SELECT 40,211,'[email protected]' FROM Dual
10 )
11 -- end of test data
12 SELECT persons_involved,
13 LTRIM (
14 MAX (SYS_CONNECT_BY_PATH (supplier, ','))
15 KEEP (DENSE_RANK LAST ORDER BY curr),
16 ','
17 )
18 AS suppliers_involved
19 FROM (SELECT persons_involved,
20 supplier,
21 ROW_NUMBER ()
22 OVER (PARTITION BY persons_involved ORDER BY supplier)
23 AS curr,
24 ROW_NUMBER ()
25 OVER (PARTITION BY persons_involved ORDER BY supplier)
26 - 1
27 AS prev
28 FROM test_tab)
29 GROUP BY persons_involved
30 CONNECT BY prev = PRIOR curr AND persons_involved = PRIOR persons_involved
31 START WITH curr = 1;
PERSONS_INVOLVE SUPPLIERS_INVOLVED
[email protected] 20
[email protected] 10,30,40
2 rows selected.
SQL>Hope this helps.
Regards,
Jo
Similar Messages
-
Query to Group records based on
Hello,
I need a help.
I have a errortable with 4 columns (pk, errordate, activestatus, errormsg). I need to get a count of the records with a pattern of errormsg but im getting lost on this, not sure where is the problem.
For example there are records with errormsg column which has logged some error msgs like say
'xxxIn-Housexxx'
'yyyCheckedInyyy',
aaaIn-Hoouseaaa',
bbbCheckedInbbb'
I'm only interested to have a count of all those with the pattern match of 'In-House' and 'CheckedIn'
this is the one i was trying, which is giving me some syntax error not sure what it is
select count(*) from error_table where errordate > sysdate - 3
group by errormsg
having
errormsg like '%In-House%'
or
errormsg like '%CheckedIn%'
I'm really confused to get a working sql for this. can you please help me.
thanksselect sum(case
when upper(errormsg) like '%IN-HOUSE%' then 1
else 0
end
) in_house_error
,sum(case
when upper(errormsg) like '%CHECKEDIN%' then 1
else 0
end
) checkedin_error
from error_table
where errordate > sysdate - 3
; -
How to get query from a record group
HI
do we get the query from which record groupis based on in oracle forms with out checking in to the properties.Hello,
No, you cannot get the initial SELECT order from the Record Group.
Francois -
How Journal Import groups records from GL_INTERFACE into Journal Headers
Hello,
Does anyone know how or using what criteria the Journal Import program groups records from the GL_INTERFACE into Journal Entries?
The R12 User Guide says that :
REFERENCE4 (Journal entry name): Enter a journal entry name for your journal entry.
Journal Import creates a default journal entry name using the following format:
(Category Name) (Currency) (Encumbrance Type ID, if applicable) (Currency
Conversion Rate, if applicable) (Currency Conversion Date, if applicable) (Originating
Balancing Segment Value), chopped to the first 100 characters. If the above results in
multiple journals in the same batch with the same name, then additional characters are
chopped off, and a 2, 3, 4, and so on, is added for the second, third, fourth, journals with
the same name.
Does it mean that for every unique combination of Category+Currency+CurrencyConversion Rate+Currency Conversion Date, a Journal Header would be created? I also found that although not mentioned in the user guide, if the Accounting Date within a group of records is different, the import program includes accounting date to the above criteria and tries to create separate Journal headers per Accounting Date.
Also, is there a way to override this ( Category+Currency+CurrencyConversion Rate+Currency Conversion Date) criteria?
Thanks,
Manishany suggessions on the above query?
Thanks & regards
Aboo -
How to modify query statement in record grp of LOV in standard form
Hi,
We are using Service contracts in Production environment.
Duplicate rows selected for LOV query.
By adding a line userenv('language') we solve the problem.
But the coding was written inside the standard "OKSITMSL.pll". Here For the Field "NAME", LOV
record group "CUST_SYSTEM" assigned dynamically based on
other fields "ITEMSEL.FILTER = SYSTEM" and "ITEMSEL.CUSTOMER_FILTER = CUSTOMER".
I have added piece of the details below.
Form is Standard form "OKSITMSL", Which is calling om parent form "OKSAUDET".
Form : OKSITMSL
Block : ITEMSEL
field : NAME
pll : OKSITMSL.pll
oksitmsl.pll coding-------------
ELSIF NAME_IN('ITEMSEL.FILTER') = 'System' THEN
If UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'CUSTOMER' then
l_group_name := 'CUST_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'RELATED' then
l_group_name := 'REL_CUST_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'BOTH' then
l_group_name := 'BOTH_SYSTEM';
Elsif UPPER(Name_In('ITEMSEL.CUSTOMER_FILTER')) = 'ALL' then
l_group_name := 'OKS_SYSTEM';
End If;
Set_Lov_Property('ITEMSEL_LEVEL', GROUP_NAME, l_group_name);
âCUST_SYSTEMâ Record group present in âOKSITMSLâ form.
I need the advice how to solve my problem by adding a line in query of "CUST_SYSTEM" record group without touching/alter standard form.
Thanks in advance.
Navasthank you shadow,
I think you mean like below:
and trim(leading 0 from a.DD_DRX_BSID_NID) = nvl(trim(to_char(SUBSTR('00042',6,5),'XXXXXXXXX')),0)
and trim(leading 0 from a.DD_DRX_BSID_BSC) = nvl(trim(to_char(SUBSTR('00042',11,5),'XXXXXXXXX')),0) ))But i think it compares with all 0's record ... but that's not correct
Edited by: josh1612 on Dec 22, 2008 2:50 AM -
dear all
I have database block with two list items.
I am populating that list from record group. it is ok.
one in country and second is city
when i try to query record it is not.
frm-40350 query caused no records to be retrieved
frm-40301 query caused no records to be retrieved
please guide me how to cover this issue.
thanks.Hi,
After entering data whether your storing the data into table.
this is my gtalk id [email protected]
Can you add it out,that would be better to help you out.
Regards
Sri -
Want to get sum/avg first 90% records in each grouped record set.
Hi Gurus,
Need your help or example query which help me to achieve sum/avg first 90% records in each grouped record set. Let me show you the basic query and output and proposed output.
select Pid, Sum(SalesAmt) TotalSaleAmt, Avg(SalesAmt) AvgSaleAmt, count(*) NoOfSales from ProductSales group by Pid;
PID TotalSaleAmt AvgSaleAmt NoOfSales
1 12000 100 120
2 24000 50 480
Now I need for PID =1 TotalSaleAmt of first 90% of NoOfSale i.e.120(this is basically nuber of rows found in PrdocutSales Table).
I hope I am clear enough explain my requirement... I would appreciate if we have some Analytical function available..
Gurus Pls help me asap..
Thanks In adavance...
Srichan.Now I need for PID =1 TotalSaleAmt of first 90% of NoOfSale i.e.120(this is basically nuber of rows found in PrdocutSales Table).
first 90% should mean first 90% by some order, so in this case, which 108 rows (of the 120) do you want to take into consideration?
with
the_sample as
(select 1 the_pid,10 the_sale,1 the_order from dual union all
select 1 the_pid,20 the_sale,2 the_order from dual union all
select 1 the_pid,15 the_sale,3 the_order from dual union all
select 1 the_pid,12 the_sale,4 the_order from dual union all
select 1 the_pid,12 the_sale,5 the_order from dual union all
select 1 the_pid,13 the_sale,6 the_order from dual union all
select 1 the_pid,19 the_sale,7 the_order from dual union all
select 1 the_pid,11 the_sale,8 the_order from dual union all
select 1 the_pid,15 the_sale,9 the_order from dual union all
select 1 the_pid,12 the_sale,10 the_order from dual union all
select 2 the_pid,25 the_sale,1 the_order from dual union all
select 2 the_pid,22 the_sale,2 the_order from dual union all
select 2 the_pid,22 the_sale,3 the_order from dual union all
select 2 the_pid,23 the_sale,4 the_order from dual union all
select 2 the_pid,29 the_sale,5 the_order from dual union all
select 2 the_pid,21 the_sale,6 the_order from dual union all
select 2 the_pid,25 the_sale,7 the_order from dual union all
select 2 the_pid,22 the_sale,8 the_order from dual
select the_pid,the_sum,the_avg
from (select the_pid,
sum(the_sale) over (partition by the_pid order by the_order) the_sum,
round(avg(the_sale) over (partition by the_pid order by the_order),2) the_avg,
the_order,
floor((0.9 * max(the_order) over (partition by the_pid))) to_pick
from the_sample
where the_order = to_pickRegards
Etbin -
Not able to see Query caused no records to be retrieved
I have created a form in master detail relation ship.
When there are no records form will give
frm 40301 Query caused no records to be retrieved.
Iam not getting this message
Otherthan this everything is working fine.
Can anyone help me in this.
Thanks
,in advancesee if this helps:
Form's messages not appearing in status bar -
How I check in group by query the group change
How I check in group by query the group change
Hi master
Sir I have master detail table
This is my query
select rownum,chartofacc.accid,title,nvl(drbal,0),nvl(crbal,0),
(select case when nvl(sum(debit),0)-nvl(sum(credit),0)>0 then
nvl(sum(debit),0)-nvl(sum(credit),0)
else
0
end mfadrttt
from voudetail where voudetail.accid=chartofacc.accid) as mfadr,
(select case when nvl(sum(credit),0)-nvl(sum(debit),0)>0 then
nvl(sum(credit),0)-nvl(sum(debit),0)
else
0
end mfacrttt
from voudetail where voudetail.accid=chartofacc.accid) as mfacr
,nvl(debit,0),nvl(credit,0),voumaster.entdate,voumaster.vno from chartofacc ,accbal,voudetail,voumaster where chartofacc.accid=accbal.accid(+) and chartofacc.accid=voudetail.accid(+) and voumaster.vno=voudetail.vno order by chartofacc.accid,voumaster.entdate,voudetail.VNO;
Sir I need add opbal from master section to debit in detail section when new group start only after adding I use that column for accumulative total or running balance
If I get any method when group change system give me any key or indication then I use
Please give me idea in both field oracle sql and oracle report 6i
Thank
aamirHi,
Please send tables structures and sample data from that tables. And, of course what should be the output. :) Just sending your query won't help us to find a solution.
Peter D. -
Using index in a query return few records than full table access
Today we have an issue with a query, when it use the ok index the returned are not all records that apply to where clause condition.
See bellow
explain plan for
select * from movdb.zan_m03 where
M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
M00za = 10 AND
m00AC = 50 AND
M00AD between 136906 and 136999
SELECT * FROM TABLE(dbms_xplan.display);
PLAN_TABLE_OUTPUT
Plan hash value: 1882720105
| Id | Operation | Name |
| 0 | SELECT STATEMENT | |
| 1 | TABLE ACCESS BY INDEX ROWID| ZAN_M03 |
|* 2 | INDEX RANGE SCAN | PK_ZAN_M03 |
Predicate Information (identified by operation id):
PLAN_TABLE_OUTPUT
2 - access("M00AF"=TO_DATE('11/01/28','YY/MM/DD') AND "M00ZA"=10 AND
"M00AC"=50 AND "M00AD">=136906 AND "M00AD"<=137141)
filter("M00AD"<=137141 AND "M00AD">=136906)
Note
- rule based optimizer used (consider using cbo)
20 rows selected.
The query above return only one row insted 1579 record that apply to this conditions.
When forcing a full table acess with a hint, the query return all records that apply, the 1579 record.
select /*+ FULL(zan_m03) */ M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
M00za = 10 AND
m00AC = 50 AND
M00AD between 136906 and 137141
Can you help me to identify what's happening?
I am with Oracle 10g R2 10.2.0.4 standard edition
the statistics are up to date
the opitimizer_mode are rule, but altering in session level to all_rows happens the same issue.
Nothing about corruption in the alert log.
Thanks in advance
Regards
CristianoYes the query are the same and correct restriction for where clause are M00AD between 136906 and 137141.
I've pasted, by mistake, another test query
The corrects are:
select M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
M00za = 10 AND
m00AC = 50 AND
M00AD between 136906 and 137141
This use pk index and return one row
select /*+ FULL(zan_m03) */ M00AF, M00za, m00AC , M00AD from movdb.zan_m03 where
M00AF = TO_DATE('11/01/28','YY/MM/DD') AND
M00za = 10 AND
m00AC = 50 AND
M00AD between 136906 and 137141
This does a full table access and return 1579 records
I´ve been searching for wrong results bugs on my oracle support, but not found one that mentions something like our issue.
I checked the dba_tables and dba indexes and the number of rows are different, and I think this would be the same because it's is a pk.
Look this
SQL> select NUM_ROWS from dba_tables where table_name = 'ZAN_M03'
2 /
NUM_ROWS
228527878
select NUM_ROWS from dba_indexes where index_name = 'PK_ZAN_M03';
SQL> select NUM_ROWS from dba_indexes where index_name = 'PK_ZAN_M03';
NUM_ROWS
217510185
Is normal a index for pk having much fewer rows than table? I think not, but not sure.
Again
Thanks in advance
Regards
Cristiano -
Query for getting records max reported timestamp and 2nd max report
query for getting records in between
max reported timestamp and 2nd max reported timestamp
HERE IS ALL RESULT SET
TIME DOMAIN
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:08:05 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:08:05 TOMCAT
PD_REPORTED_TIMESTAM PD_USER
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:08:45 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:04 TOMCAT
30:jun:2006:20:07:24 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:07:45 TOMCAT
30:jun:2006:20:08:05 TOMCAT
30:jun:2006:20:08:05 TOMCAT
PD_REPORTED_TIMESTAM PD_USER
30:jun:2006:20:08:25 TOMCAT
30:jun:2006:20:08:25 TOMCAT
QUERY RESULT TO COME
TIME DOMAIN
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
Message was edited by:
user517983Hi,
can we write query like this.
1 select pd_user,PD_REPORTED_TIMESTAMP
2 from sp_process_detail_current spdc
3 where host_id='DSCP02469'and pd_user='TOMCAT'
4 and exists(
5 select PD_REPORTED_TIMESTAMP from sp_process_detail_current
6* having max(PD_REPORTED_TIMESTAMP)-spdc.PD_REPORTED_TIMESTAMP=0)
SQL> /
PD_USER PD_REPORTED_TIMESTAM
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45
TOMCAT 30:jun:2006:20:08:45 -
SQL query to fetch records from 26 onwards
Want to know SQL query to fetch records from 26 onwards.
See the fifth entry on the FAQ page:
Re: How to attach a java bean in forms6i -
FRM 40350: Query Caused no records to be retrieved in INVTVTXN
Dear All,
When Trying to View the Material Distributions for the Transaction Type Sales Order Issue. I am unable to get the accounting entries for the Transaction. On selecting the form the error shows :
FRM 40350: Query Caused no records to be retrieved
Please help
Thanks
DineshEnsure that the cost manager is running (Inventory -> Setup -> Transactions -> InterfaceManager )...and ensure that you are giving the correct date range.
normally you should be able to see distributions as Inv valuation Cr and Deferred Cost of Goods Sold Dr ...
Some times Cost Manager shows as Active but it does not process transaction records, take help from your system administrator/ DBA to get cost manager restarted.
Thanks,
Hrishikesh -
FRM-40350: Query caused no records to be retrieved
hi
apps--12.0.6 os--IBM AIX on POWER Systems (64-bit)
When trying to find service request (e.g. 33599) throws a FORMS note: “FRM-40350: Query caused no records to be retrieved”. This is happening in FORMS.
RegardsWhen trying to find service request (e.g. 33599) throws a FORMS note: “FRM-40350: Query caused no records to be retrieved”. This is happening in FORMS.Some Service Requests Are Not Accessable - Error FRM-40350 [ID 602803.1]
Service Requests Cannot Be Retrieved When Using Folders - Error FRM-40350 [ID 744321.1]
How To Research An Item That Errors FRM-40350 And Cannot Be Queried In The Master Or Organization Items Form [ID 413104.1
Unable To Access Upgraded Service Request In the CSXSRISR Form [ID 462543.1]
R12: Cost Management Drilldown Throws ORA-01403: No data found [ID 782062.1]
FRM-92100 Error in The Workbench Tab After Find For A Service Request [ID 458115.1]
"Frm-40301: Query Caused No Records To Be Retrieved. Re-Enter" While Querying Some SRs In Create Service Request Form [ID 1324909.1]
Thanks,
Hussein -
Query Designer - Query:Specialist Group Status
Hi Gurus,
One of my BI user is getting error in this:
In Query Designer - Query:Specialist Group Status
"Registered JIT debugger is not avialable. An attempt to launch a JIT debugger with the following
command resulted in an error code of 0x2(2). please check computer settings.
cordbg.exe !a 0x289c"
but when I tried with SUPER USER access i am not getting above error.
Guys please suggest me asap
Thanks
sahadhello,
Check the variabledefinitions of the query.
Try RSRT and 'execute and debug'.
It might be you get a lot more detailed information about the problem.
see OSS note 961995.
Regards,
Dhanya
Maybe you are looking for
-
Parent Child Value Sets for Item Categories
I've tried to set up parent-child value sets, not independent-dependent sets for Item Categories but in vain. So, if Item Category has 2 segments - Category & Sub-Category; Sub-Category only shows valid values for a category. For example, if Category
-
Bug with currently selected and customised power plan.
I have reproduced this twice now. I customised my power plans (the balanced and power saver but not the high performance). My personal settings are to never sleep and for sleep not to be an option. On two occasions I have returned to the PC and found
-
Question about ESS Webdynpro application's context change
Hi All, Is it possible to add new entries into the ESS(based on ECC5.0) Webdynpro application's context especially under 'SelectedInfotype' from the back end ECC5.0 system? Kind regards, Vijay
-
Convert Word document into HTML document
Hello, I require an idea to accomplish the conversion of a .doc (word file) to .html (HTML file) in LabVIEW. I am working on a project in which i am having reports being generated after each test case execution. The data after the each test is meant
-
please help!