Concatenation of two records based on values in a column
Hello
I have the table and values as below.
create the table export_table
(TEXT varchar (255),)
Number cust_id,
PROD_SHOP varchar (100)
);
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 410,"Digital Sportsbook");
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 753,"Payments");
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 753, 'TBT');
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 753,"Digital Sportsbook");
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 999,"Digital Sportsbook");
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 999, 'TBT');
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 1593, 'TBT');
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 1593,"Digital Sportsbook");
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 1624,"Digital Sportsbook");
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 1769, 'TBT');
Insert into EXPORT_TABLE (TEXT, CUST_ID, PROD_SHOP) values (' predominant product 12 months ", 1769,"Digital Sportsbook");
commit;
Now showing current records are like
Product last 12 months | 410 | Digital sportsbook |
Product last 12 months | 753 | Payments |
Product last 12 months | 753 | OTC |
Product last 12 months | 753 | Digital sportsbook |
Product last 12 months | 999 | Digital sportsbook |
Product last 12 months | 999 | OTC |
Product last 12 months | 1593 | OTC |
Product last 12 months | 1593 | Digital sportsbook |
Product last 12 months | 1624 | Digital sportsbook |
Product last 12 months | 1769 | OTC |
Product last 12 months | 1769 | Digital sportsbook |
But I want the result form
Product last 12 months | 410 | Digital sportsbook |
Product last 12 months | 753 | Payments, TBT, digital Sportsbook |
Product last 12 months | 999 | Digital Sportsbook, OTC |
Product last 12 months | 1593 | CTA digital Sportsbook |
Product last 12 months | 1624 | Digital sportsbook |
Product last 12 months | 1769 | CTA digital Sportsbook |
How can I achieve this by using the query.
Thank you and best regards,
Mahesh
Use under request
[code]
Select text, cust_id, listagg (prod_shop, ',') WITHIN GROUP (ORDER BY prod_shop) FOR prod_shop
of export_table
Group by text, cust_id.
[/ code]
Concerning
Arun
Tags: Database
Similar Questions
-
To summarize two records based on Max Date
Hello
I have the following data:
Account number Date of invoice Invoice Amt Real AMT Companies code 10011 10/11/2013 100.02 93.03 0112 10011 10/02/2014 93.04 87.76 0232 I need to sum up above two records based on max (Invoice Date) and and I need to display company code corresponding to the date of billing max
Expected result:
Account number Date of invoice Invoice Amt Real AMT Companies code 10011 10/02/2014 193.06 180.79 0232 Thank you
Kiran
Hello
Try this:
with in_data as
(
Select '10011' account_number, dates "2013-11-10' invoice_date, invoice_amt 100.02, 93,03 actual_amt '0112' company_code of all the double union"
Select '10011,' date '' 2014-02-10, 93.04, 87.76, '0232' from dual
)Select
Account_Number
max (invoice_date) i_date
sum (invoice_amt) i_amt
sum (actual_amt) a_amt
, max (company_code) Dungeon c_code (last dense_rank command by invoice_date)
Of
in_dataGroup
Account_Number
;ACCOUNT_NUMBER I_DATE I_AMT A_AMT C_CODE
-------------- --------- ------ ------ ------
10011 10 FEBRUARY 14 193.06 180,79 0232Kind regards
Peter
-
concatenation error - when I use the value of the column of text in which the condition.
Hello
I'm creating Materialized view using a few columns from two tables and by obligation, I need to prepare a select statement with a where condition in another column. (new heading)
I tried like below...
create a materialized view HAND
force refresh on demand
as
Select
a.table_name,
a.column_name,
b.trial_name,
' Select * from ' | '. a.table_name |' where ' | a.column_name | ' = '|| b.trial_name | « ; » "QUERY".
Of
exp_csv_tB has,
b exp_csv_tr;
the value of name a.table is: monitoring_table
a.column_name value is: study
b.trial_name = fty777
Materialized view created with an extra column, but it is not added "(codes) to the value of the text in which the condition.
output I got is:
Select * from monitoring_table where study = fty777;
but
I need output like
Select * from monitoring_table where to study = "fty777";
value of fty777 must be in the codes like "fty777". I read a few articles, but did not get this example.
Help, please.You need to escape your quotes (double upward on quote)
create materialized view MAIN refresh force on demand as select a.table_name, a.column_name, b.trial_name, 'select * from '||a.table_name||' where '||a.column_name|| ' = '''|| b.trial_name||''';' "QUERY" from exp_csv_tB a, exp_csv_tr b;
-
concatenation of lines having the same value of the column
Hi all
I was struck with a situation, please find the example in the following table
create table test (varchar2 (20) Column1, Column2 varchar2 (20), Column3 varchar2 (20))
Insert test values ('A1', 'x 1', 's1');
Insert test values ('A1', 'x 1', 's2');
Insert test values ('A1', 'x 1', 's4');
Insert test values ('A1', 'x 2', 's1');
Insert test values ('A1', 'x 2', 's2');
Insert test values ('A1', 'x 2', 's3');
so finally the teable looks like this
Column1 - Column2 - Column3
A1-----------------------x1------------------------s1
A1-----------------------x1------------------------s2
A1-----------------------x1------------------------s4
A1-----------------------x2------------------------s1
A1-----------------------x2------------------------s2
A1-----------------------x2------------------------s3
so now I want the o/p, based on common values for i.e Column2 Column3
Column1 - Column2 - Column3
A1-----------------------x1,x2-------------------s1,s2
A1-----------------------x1------------------------s4
A1-----------------------x2------------------------s3
How this could be achieved, any help would be appreciated
Thank you
SimiYou can use wm_concat... but are not documented in 10g
SELECT column1, column2 , wm_concat(column3) FROM (SELECT column1 , wm_concat(column2) column2, MAX(column3) column3 FROM test GROUP BY column1, column3 ) GROUP BY column1, column2;
Ravi Kumar
-
Need to set the attribute of the current record based on the value of the next record
With the help of forms 6, I have a form that displays the list of folders. There may be multiple records with the same ID, but with different expiration dates. I need set attributes for hilite only the record with the latest expiration date. The current list points of interest reviews of future expiration dates - but we found that, sometimes, the subscription is renewed before the expiration date has been reached, causing two records with the same ID with expiry dates in the future.
I can (and do) sort the records by date of expiry and the identification for the record with the latest expiration date is always the last to this ID, so what I want to do is to check the next record to see whether or not it has a different ID. If the current record is the last expiration date, & must be hilited. Because I might want to hilite the current record, I can't simply navigate to another record, according to the description I found, what makes the next_record builtin. Anyone know how I can check for a value in the next record without making the current record?
Thank you.What I would do:
-Create a DB view based on your table and including the function call DRIVE as a separate column.
-Base that block you on this point of view
-If the block is modifiable, set the DML target for the block to your database table. -
two different decomposable based on values in rtf
Hi all
For a column of rtf, can we have drill several way, based on the values in the column. For example, if the value is > 10 000 navigate (hyperlink) to report a navigate (hyperlink) otherwise to report B.
Obiee answering the link of action, we can put condition, but BI Publisher using the rtf, is it possible to perform several drill down to the same column.
Thank you
Sushil
Thanks for your suggestion. I tried in the rtf, I'm not able to include inside the value. I send a sample rtf and xml for your kind reference.
Thank you
Sushil
-
How to recover new logical column based on values of table hint.
Hello
I have two tables in SPR
1. file table contains the coulmns-> date, numero_fichier, record_count, cldm_stg, cmsa_stg, archive_stg
2 rejection table columns are--> same as above
both have same common requirement of columns.my is to publish a dashboard as:
Date | County land_files | alnd_recordscount | County target_files | target_records County | Rejection filecount | number of records release
These report ineed recover from these two tables.based on countcomes values.taget flag when all values of ILI value = 'y '.
IE (cldm_stg = 'y' and cmsa_stg = 'y' and archive_stg = 'y') if not then it will be in the release file.
Please give solution how to achieve my output.
[nQSError: 14026] Impossible to navigate the requested term: Target_record: [DAggr (FILE_CONTROL. Target_record by [FILE_CONTROL. FILE_NAME, REJECTED_FILES. File_name, REJECTED_FILES.NO_OF_ROWS, File_landing.NO_OF_ROWS, File_landing. (FILE_LOAD_DATE] SB FILE_CONTROL)]. Correct metadata consistency warnings. (HY000)
Published by: user8767586 on January 12, 2010 04:29First answer the following questions:
What is your fact table?
What are your dimension tables? -
Draw lines based on values from database
I want to draw the line based on the data from database.
Number of lines will be the number of records in the query.
line length will be based on the value of the column in centimetres.
by example, if the query selects 3 folders 3 lines will be drawn.
If the first record column value is 5 then 5 cm line will be drawn.
Thank you.
Please find the sample report and xml.
Kaya.
-
The column that does not match when comparing two records
Hi all
We try to compare two tables and find the differences. So if two records (1 of each table) have same PK but not always matching because of some columns, then we would display this columnname. For example:
Table 1
PK Parent Child Property1 Property2 1 A A1 P1 PR1 2 B B1 P2 oraPR2 3 C C1 P3 SRP Table 2
PK Parent Child Property1 Property2 1 A A1 P1 PR1 2 B B1 P2 PR2 3 C C1 P3 PR4 In the above example when I compare 2 tables all matches except Property2 online n ° 3. Thus, we would like to get an output like:
PK Column_Mismatch 3 Property2 (this must be the name of the column that does not match) Appreciate the help.
Thank you
Andy
Hi, Andy.
Andy1484 wrote:
Hi all
We try to compare two tables and find the differences. So if two records (1 of each table) have same PK but not always matching because of some columns, then we would display this columnname. For example:
Table 1
PK Parent Child Property1 Property2 1 A A1 P1 PR1 2 B B1 P2 oraPR2 3 C C1 P3 PR3 Table 2
PK Parent Child Property1 Property2 1 A A1 P1 PR1 2 B B1 P2 PR2 3 C C1 P3 PR4 In the above example when I compare 2 tables all matches except Property2 online n ° 3. Thus, we would like to get an output like:
PK Column_Mismatch 3 Property2 (this must be the name of the column that does not match) Appreciate the help.
Thank you
Andy
Why you don't want no matter what exit for pk = 2? Property2 does not correspond either to pk.
What happens if the 2 columns (or more) do not match? The following query would produce a list delimited, such as ' parents; PROPERTY2 '.
WITH got_mismatch AS
(
SELECT pk
, CASE WHEN t1.parent <> t2.parent THEN '; PARENT' END
|| CASE WHEN t1.child <> t2.child THEN '; CHILD ' END
|| CASE WHEN t1.properry1 <> t2.property1 THEN '; PROPERTY1 ' END
|| CASE WHEN t1.properry2 <> t2.property2 THEN '; PROPERTY2 ' END
AS the offset
FROM table_1 t1
JOIN table_2 t2 ON t2.pk = t1.pk
)
SELECT pk
, SUBSTR (incompatibility, 3) AS column_mismatch
OF got_mismatch
WHERE mismatch IS NOT NULL
;
If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.
The query above does not count NULL values as inadequate. If you want that, the same basic approach will work, but you can use DECODE instead of <> to compare columns.
What happens if a pk exist in a table, but not the other? You want an outer join, where I used an inner join above.
-
Need add/update two records on click on the create/update button
I have a table with 5 columns
1 ID - primary key
2 name
3. address
4 CARB
5 KADER
Now whenever I do an insert in this table to this table I have to add two rows, as shown below:
1st row - (name1, Add1, 717, 717)
2nd place - (name1, Add1, 515, 515)
Name and address values are entries of the screen and the CARB & KADER values are fixed (717 or 515). So for each click on the button create two records needs to be inserted.
Even when I update to say record particular Carb - 717 & kader-717, I must also update other file too Carb-515 & kader-515. For each click on the update button, so I need to update two records.
Please tell me as to how I will do this
Hello
Why do you not use insert manual and update according to your requirement process?... Gives 'Never' for automatic processing of the DML and try to create a manual process (PL/SQL blocks) and give the condition.
Thank you
Lacombe
-
You will need to change based on values in another article LOV...
Hi all
I got a mudbrick THAT LOV based on a value in another column. Let me explain... Assume that A value in the column is A1 then column B should show A11, A12, A13 and if column A is the value C cloumn B should show C11, C12... etc. The LOV will be static with some pre defined values. So all the LOVs will be defined in the forms. We just need to show based on the value in column A.
Please suggest.
Thank you.
Published by: Amit1cs on April 18, 2013 19:40Amit1cs wrote:
Hi allI got a mudbrick THAT LOV based on a value in another column. Let me explain... Assume that A value in the column is A1 then column B should show A11, A12, A13 and if column A is the value C cloumn B should show C11, C12... etc. The LOV will be static with some pre defined values. So all the LOVs will be defined in the forms. We just need to show based on the value in column A.
Please suggest.
Hello Amit,
Up to now, I understand, you can create several record group for a single LOV. before you display the lov just to change or assign the appropriate record group. You can use pre-text-element column B trigger and set the record group to your LOV.Hope this helps
Hamid
-
Generating lines based on the value of the column?
Hi all
I would like to know if there is a function that can help me in creating lines based on a column value and, if so, which. I'm on version 11.2.0.3.0
for example, I have these data in the table:
ID O A C
1 5 3 5
2 9 2 3
Where ID is an identifier unique record and column C contains the number of records, I would have returned for this ID. In this example, the folder with the ID 1 would be repeated 5 times and the folder with the id 2 would be repeated 3 times. The result would look like this:
ID O A C
1 5 3 5
1 5 3 5
1 5 3 5
1 5 3 5
1 5 3 5
2 9 2 3
2 9 2 3
2 9 2 3
Column C contains the number of repetitions Records and is defined as a positive integer > = 1.
Of course, in real life, the table contains (at this time) 41 M number of records and the value of C can vary between 1 and 554, hardcode on the example above values is not possible.
Any pointers in the right direction are much appreciated.
Kind regards
LennertSQL> ed Wrote file afiedt.buf 1 with t as (select 1 as id, 5 as c from dual union all 2 select 2, 3 from dual) 3 -- 4 select id, c 5 from t 6 connect by level <= c 7 and id = prior id 8* and prior sys_guid() is not null SQL> / ID C ---------- ---------- 1 5 1 5 1 5 1 5 1 5 2 3 2 3 2 3 8 rows selected.
-
Merge two records which has the same ID
Hi all
Oracle version-> database Oracle 10 g Enterprise Edition Release 10.2.0.4.0 - 64 bit
Has obtained two records with DB_ID even on different creation_dates, but some columns are filled in on the next day with the updated data. Now I need merge them into one by taking the MAXIMUM of the columnTable DB_TEMP create table DB_TEMP ( Db_ID NUMBER, LAST_NAME VARCHAR2(30), FIRST_NAME VARCHAR2(30), MIDDLE_NAME VARCHAR2(30), M_CODE VARCHAR2(10), PREFIX VARCHAR2(30), TITLE VARCHAR2(100),CREATION_DATE DATE); INSERT INTO DB_TEMP values (3, 'JOHN', 'KER', '', 'A146', '', 'PRESIDENT', '5/1/2011'); INSERT INTO DB_TEMP values (3, 'JOHN', 'KER', '', '', 'MR', 'PRESIDENT ACTIVE HERE', '5/10/2011'); INSERT INTO DB_TEMP values (11, 'MATT', 'CARLONE', '', '', 'MR', 'CHAIRMAN', '5/1/2011'); INSERT INTO DB_TEMP values (11, 'MATT', 'CARLONE', '', 'A149', '', 'CHAIRMAN INACTIVE', '5/10/2011'); INSERT INTO DB_TEMP values (40, 'JOHN', 'SMITH', 'K', 'A147', '', 'PRESIDENT', '5/1/2011'); INSERT INTO DB_TEMP values (40, 'JOHN', 'SMITH', 'K', 'A147', 'MR', '', '5/10/2011'); Required Output DB_ID LAST_NAME FIRST_NAME MIDDLE_NAME M_CODE PREFIX TITLE CREATION_DATE --------------------------------------------------------------------------------------------------------------------------------------------- 3 JOHN KER A146 MR PRESIDENT ACTIVE HERE 5/10/2011 11 MATT CARLONE A149 MR CHAIRMAN INACTIVE 5/10/2011 40 JOHN SMITH K A147 MR PRESIDENT 5/10/2011
Help, please
Thank you
Published by: 960736 on November 9, 2012 10:12
Published by: 960736 on November 9, 2012 10:27
Published by: 960736 on November 9, 2012 10:48Hello
960736 wrote:
I need complete records for title CONCATENATE them with ';' in the meantime, but title that has the M_CODE should must be first if not in does not matter in any order. Any remaining can be Max.DB_ID LAST_NAME FIRST_NAME MIDDLE_NAME M_CODE PREFIX TITLE CREATION_DATE --------------------------------------------------------------------------------------------------------------------------------------------- 3 JOHN KER A146 MR PRESIDENT ACTIVE HERE;Member 5/10/2011 11 MATT CARLONE A149 MR CHAIRMAN INACTIVE 5/10/2011
So, for db_id = 3, wouldn't you ' PRESIDENT; PRESIDENT ACTIVE HERE; MEMBER "?"
For db_id = 11, wouldn't you ' PRESIDENT; INACTIVE PRESIDENT '?Whatever it is, you need the string aggregation . See this page from the Oracle Base for several ways to do so. Since you have Oracle 10 and because the order is not important, I recommend so the aggregate function defined by the user, called STRING_AGG on that page, but the STRAGG called by most of the people who actually use it. Once you have created the STRAGG, you can use it like this:
SELECT db_id , MAX (last_name) AS last_name , MAX (first_name) AS first_name , MAX (middle_name) AS middle_name , MAX (m_code) AS m_code , MAX (prefix) AS prefix , STRAGG (title) -- or STRAGG (DISTINCT title) AS title , MAX (creation_date) AS creation_date FROM db_temp GROUP BY db_id ;
-
create dynamically a group of record based on previously entered record Grou
Forms [32 bit] Version 10.1.2.3.0 (Production)
Hello
I know how to create dynamically record based on a query and put the code in when a new instance of the form.
My request is. I have a form that includes several groups of Record and the user wants to dynamically create the following groups based on the previous groups.
For example
I have a record group with choosing a location.
When the user selects the location from a list of values
the 2nd record group called "Cost Centres" will have to filter only those whose locations selected above.
How can I fill the 2nd record running when I don't know what site the user will choose?
If I just simply fill in when new instance of form as the location and just select the entire document, populates the list of values.
CC field is a LIST ELEMENT and the style of list is a LIST of POP, is not necessary.
I put the code in the location of the trigger when-list-changed field.
I get this error:
FRM-41337: cannot complete the record group list
Here is the code:
Thanks for your help.DECLARE v_recsql Varchar2(1000); -- The SQL for creating the Record Group. v_recgrp RecordGroup; -- Record Group v_status Number; -- Return Value of Populate_Group function. c_where VARCHAR2(1000); BEGIN IF :location = '1' THEN c_where := ' substr(cost_centre,1,2) in (''01'',''02'')'; ELSIF :location = '2' THEN c_where := ' substr(cost_centre,1,2) in (''02'',''03'')'; ELSIF :location = '3' THEN c_where := ' substr(cost_centre,1,2) in (''01'',''11'',''07'')'; ELSE c_where := ' 1=1'; --EVERYTHING END IF; v_recsql := 'SELECT cost_centre, description FROM cost_centres where '||c_where; -- Create the Record Group v_recgrp := CREATE_GROUP_FROM_QUERY('v_recgrp', v_recsql); IF NOT ID_NULL(v_recgrp) THEN -- No Error, record group has been successfully created. -- Populate Record Group v_status := POPULATE_GROUP('v_recgrp'); IF v_status = 0 THEN -- No Error. Record Group has been Populated. POPULATE_LIST('block.CC', 'v_recgrp'); END IF; -- IF v_status = 0 -- Delete the Record Group as it is no longer needed. DELETE_GROUP('v_recgrp'); END IF; -- IF NOT ID_NULL(v_recgrp) END;
Hello
Once registration State Gets the change to block you cannot fill/repopulate the list item. Keep these list items as element non-base of data with different names and create different items such as database Moose points. That assign values in triggering WHEN-LIST-CHANGE for real database items.-Clément
-
How can I fill the records using the value LOV
Create a form based on the use of the following output Table EMP
Create a database block IE control-> Dept No. block
Create a database block - EMP
Create a LOV to the Dept not according to the dept table.
For the current No. Dept. Complete records of the employees
How can I fill the records using the value LOV?
Thank youHello
Create trigger KEY-LISTVAL for control_block.dept_no with code similar to the following:
IF SHOW_LOV ('LOV_NAME') THEN SET_BLOCK_PROPERTY ('EMP_BLOCK', DEFAULT_WHERE, 'DEPT_NO = ' || :CONTROL_BLOCK.DEPT_NO); GO_BLOCK ('EMP_BLOCK'); EXECUTE_QUERY; END IF;
Hope this helps
Best regards
Arif Khadas
Maybe you are looking for
-
iBooks doesn't work on ios 9.3 and 9.3.1. ideas for fixing?
Hello guys,. Since I upgraded my iphone 6 ibooks ios 9.3 or also 9.3.1 is completely unusable. Because I can't jump to ios 9.2 more that I really need to solve this problem. I have a collection quite important PDFs, ebooks (not bought through itunes)
-
CFSServ.exe error appears on Satellite L20
HelloI get an error that appears when I start my laptop L20. It's basically one of those windows error boxes and it reads "CFSServ.exe has encountered a problem and needs to close. We are sorry for the inconvenience. » He started this a week or two t
-
Have just got a 550qe of Pavilion and can not find the place where the monitor. The image on the book they sent shows the exact card, I need but can't find anywhere on the back of the PC. There are a few plates little who have the drivers there,
-
Can not find the driver I need to download
Should which driver I for the Microsoft Wireless Comfort Keyboard 4000? Not the 5000 or the Natural Ergonomic 4000... None of the listed factors are specified for the Comfort Keyboard 4000.
-
I can't access my account because the program does not recognize my password.
It's like a catch22. I can't login to my account to get answers on how to uninstall progrtam antivirus that is not listed in programs and features, but in the actual program files, which will not uninstall. My password is not recognized by microsoft,