Splitting of records into different rows
Hi,
I have a table 'test' which has three columns :
ID varchar2(10), Product varchar2(100), source varchar2(100).
I have provided two sample records below :
ID PRODUCT SOURCE
ID1 | P1,P2 | S1,S2
ID2 | P1,P3 | S2,S3
I need to split the product and source values (they are comma separated) and make different rows out of them. The result set required looks like below :
ID PRODUCT SOURCE
ID1 | P1 | S1
ID1 | P1 | S2
ID1 | P2 | S1
ID1 | P2 | S2
ID2 | P1 | S2
ID2 | P1 | S3
ID2 | P3 | S2
ID2 | P3 | S3
Could someone help me regarding this ? The number of comma separated values will be dynamic and we can have null between two commas too.
Kind regards,
Mainak
Edited by: user11183570 on Jul 14, 2011 4:43 AM
SQL> CREATE TABLE test (ID varchar2(10), Product varchar2(100), source varchar2(100));
Table created.
SQL> insert into test values ('id1','P1,P2','S1,S2');
1 row created.
SQL> insert into test values('id2','P1,P3','S2,S3');
1 row created.
SQL> commit;
Commit complete.
SQL> WITH tbl AS
( SELECT DISTINCT id col1,
regexp_substr (product, '[^,]+', 1, level) col2 ,
source col3
FROM test
CONNECT BY level <= LENGTH (regexp_replace (product, '[^,]+')) + 1
SELECT DISTINCT col1,
col2,
regexp_substr (col3, '[^,]+', 1, level) col3
FROM tbl
CONNECT BY level <= LENGTH (regexp_replace (col3, '[^,]+')) + 1
ORDER BY 1; 2 3 4 5 6 7 8 9 10 11 12 13
Similar Messages
-
ALV GRID report( displayin one record into different rows)
Dear ABAPERS,
i have a request in ALV report. The requirement like
EX: i have a 10 fields in internal table, i want display 5 fields in one row , 3 fields in one row and 2 fields in 3rd row. pleaz suggest the solution.
thanks and regards,
JP Reddy.JP,
Below thread might help you for your requirement
ALV grid Multiple Header ... ?
Thanks,
Chandra -
Split a record into multiple records
Hi,
I have situation where i need to split a record into multiple records.
InputData :
value|BeginDate |EndDate
15 |2002/10/15|2002/10/16
13 |2002/10/13|2002/10/20
19 |2002/10/19|2002/10/23
10 |2002/10/10|2002/10/12
OutPut :
10 |2002/10/10|2002/10/12
13 |2002/10/13|2002/10/15
15 |2002/10/15|2002/10/16
13 |2002/10/16|2002/10/19
19 |2002/10/19|2002/10/23
ThanksHi ,
As a far I understood from your example ,
I have few questions...
1. You have information about the patient in a 1 source table.
2. how u are identifying for patient X u need 5 rows to be created. R u storing these informations in seprate table or how ...
3. if you have these information in a seperate tables ..... a simple cross join in ODI should get you the expected result.....
Or give some more information with a example ..that would be great ...
Thanks -
Rejected records into different Table.
Hi ,
I have a .ctl file and .txt file. for the normal scenario, I use SQLLDR to load data into my table using ctl file and all rejected records will be sent to bad files. But I wanted all the unloaded or Bad records into different table.
do we have any attributes in sqlldr to accomplish this?
Regards
Bala.Bala,
You can load bad file (rejected records) in different table with all the column defined as varchar2 using sqlldr or external table. But you have to defined another table with all the columns as varchar2 and load it up using a different sqlldr control file, you can also consider using external table to load bad file (bad records).
Regards -
How to split one page into different frames in ADF?
Hi,
Can any one please guide me how to split a jspx into different frames.
i.e., left frame contains <af:panelSideBar> which contains multiple <af:commandMenuItem> s. And whenver we click on the one <af:commandMenuItem>, it has to show the corresponing page inside center frame in this page itself. Is it possible in ADF? Which component we need to use?
Can anyone guide me on this?
Thanks in advance,
Regards,
Suresh KethireddyYou can use a combination of the ADF Faces 10.1.3 components like:
af:panelPage
af:panelSideBar
af:panelHorizontal
af:panelGroup
to organize the screen layout, but it is not the interactive splitter that the 11g product provides.
You can all all the 10.1.3 ADF Faces Components here:
http://www.oracle.com/technology/products/jdev/htdocs/partners/addins/exchange/jsf/doc/tagdoc/core/imageIndex.html -
Splitting one column into different columns.
Hello Experts,
How do i split datetime column into different columns while doing a Select statement.
Ex:
The column "REC_CRT_TS" has data like "2014-05-08 08:23:09.0000000".The datatype of this column is "DateTime". And i want it in SELECT statement like;
SELECT
YEAR(DATETIME) YEAR,
MONTH(DATETIME) MONTH,
DATENAME(DATETIME) MONTHNAME,
DATEPART(DATETIME) WEEKNUM,
DAY(DATETIME) DATE,
DATEPART(DATETIME) HOUR
FROM TABLE_NAME;
The output should look like this;
--YEAR| MONTH | MONTHNAME| WEEKNUM | DATE | HOUR
--2014| 5 | May | 25 | 08 |08
Any suggestions please.
Thanks!
RahmanI made a very quick research and I see in this blog post
http://www.jamesserra.com/archive/2011/08/microsoft-sql-server-parallel-data-warehouse-pdw-explained/
that It also uses its own query engine and not all features of SQL
Server are supported. So, you might not be able to use all your DBA tricks. And you wouldn’t want to build a solution against SQL Server and then just hope to upsize it to Parallel Data Warehouse Edition.
So, it is quite possible that this function doesn't exist in PDW version of SQL
Server. In this case you may want to implement case based month name or do it in the client application.
For every expert, there is an equal and opposite expert. - Becker's Law
My blog
My TechNet articles -
Splitting a long recording into different songs?
Some friends and I will be recording today and there are a few things I am unsure about.
First, we usually play for about 2 hours nonstop and we will be recording 3 simultaneous tracks. After the session, I would like to export the recording into itunes. But, instead of one 2 hour song, I would like to split it up into multiple songs. How would i do this?
Second, to record nonstop for 2 hours, do i need to adjust the tempo of the recording before we start in order to maximize the time we can record. I thought I saw someone say that you had to lower the tempo to 40 to record for a few hours. I couldn't find the post though so could someone let me know if this is correct?
Thanks!I would like to split it up into multiple songs.
http://www.bulletsandbones.com/GB/GBFAQ.html#exportexactlength
I thought I saw someone say that you had to lower the tempo to 40 to record for a few hours
http://www.bulletsandbones.com/GB/GBFAQ.html#recordlength -
Split one record into multiple records in Update Rules
Hello All,
I am trying to split a single record from R/3 into 2 records.
My data flow is form R/3 > PSA > ODS > Cube
when loading data into ODS i have to add the original record as it is to ODS. For second record i have to check a condition, & change few keyfigure values to 0 and fill an extra field.
Example:
Record in R/3 :
Month | %1 | %2 | %3 | % 4 | ORGUNIT | JOB| EMPLOYEE| POSITION|
02.2006 | 0 | 1 | 0 | 0 | 3000000| 248 | 2546352 | 500000 |
Record in BW Comm_Structure.
In Transfer rules i m writing an extra field to the R/3 record.
Month | %1 | %2 | %3 | % 4 | ORGUNIT | JOB| EMPLOYEE| POSITION| NEW_FIELD |
02.2006 | 0 | 1 | 0 | 0 | 3000000| 248 | 2546352 | 500000 | 2546352 |
NEW_FIELD transfer routine :
If employee NE 0
Result = employee
else.
Result = 0 .
Till this point everything works fine.
Now i want to load this record into an ODS. I want to split the above single record into 2 records.
Records in ODS should be :
Month | %1 | %2 | %3 | % 4 | ORGUNIT | JOB| EMPLOYEE| POSITION| NEW_FIELD |
02.2006 | 0 | 1 | 0 | 0 | 3000000| 248 | 2546352 | 500000 | 0 |
02.2006 | 0 | 0 | 0 | 0 | 3000000| 248 | 2546352 | 500000 | 2546352 |
Condition for NEW_FIELD.
For first record always NEW_FIELD =0.
For Second Record
If NEW_FIELD NE 0.
Cahnge KF's %1, %2, %3, %4 = 0.
If EMPLOYEE is 0 then no need to create extra record.
I tried to use achieve this using return table, but no success.
Can any one help me with ABAP syntax please. I am bit weak in ABAP Programming.
Thanks in advance.
POPSDear:
You could do so in update routines. Select the 'return table' option.
useful links:
https://forums.sdn.sap.com/click.jspa?searchID=10118555&messageID=2906656
https://forums.sdn.sap.com/click.jspa?searchID=10118555&messageID=913873
https://forums.sdn.sap.com/click.jspa?searchID=10118555&messageID=2441579
Thanks -
Split table record into several lines - pdf forms
hello experts
im trying to split a table record into several lines in order to present the whole table record in the form.
for example:
table T has 4 fields F1 F2 F3 F4
if the tables has 2 records - R1 and R2 (every record contains 4 data fields) then i want to present my table in the following way:
R1-F1 R1-F2
R1-F3 R1-F4
R2-F1 R2-F2
R2-F3 R2-F4
please do not refer me to links - i really need a specific procedure
thanks ahead to all
Eyal
P.S i am using the adobe lifecycle - SFP tran.hey everyone
it has been solved
for the record:
subform table (flowed content) contains 2 positioned subforms
subforn header
subform lines contains 2 flowed subforms 1 for the first two fields and 1 for the ladt two fields
thank anyway
Eyal -
Easy Question: How to split concatenated string into multiple rows?
Hi folks,
this might be an easy question.
How can I split a concatenated string into multiple rows using SQL query?
INPUT:
select 'AAA,BBB,CC,DDDD' as data from dualDelimiter = ','
Expected output:
data
AAA
BBB
CCC
DDDDI'm looking for something kind of "an opposite for 'sys_connect_by_path'" function.
Thanks,
TomasHere is the SUBSTR/INSTR version of the solution:
SQL> WITH test_data AS
2 (
3 SELECT ',' || 'AAA,BBB,CC,DDDD' || ',' AS DATA FROM DUAL
4 )
5 SELECT SUBSTR
6 (
7 DATA
8 , INSTR
9 (
10 DATA
11 , ','
12 , 1
13 , LEVEL
14 ) + 1
15 , INSTR
16 (
17 DATA
18 , ','
19 , 1
20 , LEVEL + 1
21 ) -
22 INSTR
23 (
24 DATA
25 , ','
26 , 1
27 , LEVEL
28 ) - 1
29 ) AS NEW_STRING
30 FROM test_data
31 CONNECT BY LEVEL <= LENGTH(REGEXP_REPLACE(DATA,'[^,]','')) - 1
32 /
NEW_STRING
AAA
BBB
CC
DDDD -
How to split the records into two parts
Hi experts,
I have a field with 75 char length, this field have records also, Now i want to split the field into two differnt fields. That means upto first 40 char goes to one field, from 41st char to 70 char goes to another field, for that how to split record into two parts.
Plz advice this,
MohanaHi,
Do the following:
f1 = fsource(40).
f2 = fsource+40(30).
where fsource is the 70 character original string and target strings are f1 (length 40) and f2 (length 30).
Cheers,
Aditya
Edited by: Aditya Laud on Feb 22, 2008 2:10 AM -
INSERT of two records into different tables (pk value from first to second)
Hi there!
Have probably stupid question
Need to insert one record into table with primary key and then insert into other table record with value of primary key field from first record
How can I do it?
Thanks a lot!!!You have several possibilities. Most easiest one is listed first :)
SQL> create table a (a number);
Table created.
SQL> alter table a add constraint a_pk primary key (a);
Table altered.
SQL> create table b (a number);
Table created.
SQL> alter table b add constraint b_a_fk foreign key (a) references a(a);
Table altered.
SQL> insert into a values (0);
1 row created.
SQL> insert into b values (0);
1 row created.Though that may not help always, so the next possibility maybe just using sequence with nextval and currval (currval can be used only in the same session and only after you have issued at least one nextval)
SQL> create sequence a_seq;
Sequence created.
SQL> insert into a values (a_seq.nextval);
1 row created.
SQL> insert into b values (a_seq.currval);
1 row created.And you can use also famous returning clause. It is a bit easier to show that in the pl/sql block than pure SQL.
SQL> declare
2 v number;
3 begin
4 insert into a values (a_seq.nextval) returning a into v;
5 insert into b values (v);
6 end;
7 /
PL/SQL procedure successfully completed.And at last contents of the tables :)
SQL> select * from b;
A
0
1
2
SQL> select * from a;
A
0
1
2Gints Plivna
http://www.gplivna.eu -
How To Split One Record into 30 Records(Number of days in a Month)
Hi Experts,
we are getting the montly(yearmonth) Forecast data from flat file we need to generate the report which shows the daily Forecast data,
For example for the month of June Forecast we have 150EA.
Flat file data is like this
0calday Qty
201006 150
we need to show the report like datawise
Calday Forecast qty
20100601 5
20100602 5
20100603 5
20100604 5
20100605 5
20100606 5
20100630 5
its like month forecast / Number of days in a month.
we can achive these in two ways as per my knowledge
1. At the time loading data
2. Reporting level
Which is the best way
how can we achive this.
Thanks
ChandraHey. There was a similar posting I gave a suggestion on a while back. Here is the link...
Re: Spliting records into cube
As far as the correct time of doing this, I would definitely do this at the time of data load and not time of reporting.
Hope you find it helpful.
Thanks -
How to break one row records into 3 row records
I have two tables which consists of date records,
table1
first_date second_date
01-feb-10 01-mar-10
tabl2
new_date old_date
01-jan-10 01-aug-10
if first table dates falls between new_date and old_dates, i need to showit as three row records instead of1 row in table2Hi,
1001383 wrote:
I have two tables which consists of date records,
table1
first_date second_date
01-feb-10 01-mar-10
tabl2
new_date old_date
01-jan-10 01-aug-10
if first table dates falls between new_date and old_dates, i need to showit as three row records instead of1 row in table2Do both first_date and second_date have to fall between old_date and new_date, or is it enough if either one does?
What do you want to see on those 3 rows?
Depending on your data and your requirements, here's one way:
WITH cntr AS
SELECT LEVEL AS n
FROM dual
CONNECT BY LEVEL <= 3
SELECT t2.*
FROM table2 t2
CROSS JOIN cntr
WHERE EXISTS (
' SELECT 1
FROM table1 t1
WHERE t1.first_date BETWEEN t2.old_date AND t2.new_date
OR t1.second_date BETWEEN t2.old_date AND t2.new_date
;I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements) for both tables, and the results you want from that data.
Include examples of any special situations you need to handle, such as the same row in table2 matching several rows in table1.
See the forum FAQ {message:id=9360002} -
Spliting a record into multiple rows
Hi experts, need your help for your to frame a query for the below requirement
Scenario 1
For a same store fetch the record with least priority (35) and check if the Servicearea begin date & Servicearea end date of that store is minimum for that group.
If minimum then select that record alone as shown below
Item DC Store Serviceare Bgn Date Service Area End date Priority
9856698 1469 2952 3/5/2011 12/31/9999 100
9856698 3107 2952 12/10/2011 8/3/2012 35
Item DC Store St Date End date Priority
9856698 3107 2952 12/10/2011 8/3/2012 35
Scenario 2
For a same store fetch the record with least priority (35) and check if the Servicearea begin date & Servicearea end date of that store is minimum for that group.
If not minimum split the records for that group as shown below and select the record which has the lowest priority(35) and with minimum startdate and end date range.
Item DC Store Serviceare Bgn Date Service Area End date Priority
9856698 1469 2952 3/5/2011 12/31/9999 35
9856698 3107 2952 12/10/2011 8/3/2012 100
Item DC Store St Date End date Priority
9856698 1469 2952 3/5/2011 12/9/2011 35
9856698 3107 2952 12/10/2011 8/3/2012 100
9856698 1469 2952 8/4/2012 12/31/9999 35There is a seperate forum for SQL and PL/SQL.
You need to post this at :
PL/SQL
And mark this thread as answered if possible.
Maybe you are looking for
-
Search a solution to connect WebDynpro app in CE 7.2 to KM in EP 7.0
Hello all I have 2 servers federated, in one of them is installed EP 7.0 and the other has installed CE 7.2 I wonder if it is possibble to connect KM in the EP 7.0 through a WebDynpro application in CE 7.2 I mean, I´m searching a solution to access
-
I'm trying to connect the Iphone 5 to the Surface Pro 128. I wish I could connect with wireless connection, but is it true I must use usb first? And then, since there is only usb 3 on the surface, would that work?
-
Hi, I have a little problem with Edge. I created an animation and when I preview this from my hard disc everything works fine. But when I upload files to my host, animation disappears. I found this thread and I tried those tips but still nothing. htt
-
New Appointment creation in Meeting Room exception
Dear KMC experts, I have a problem while creating new appointment in the collaboration room based on template "<b>Meeting Room</b>" on SAP EP KMC SPS 14. When I fill in all the information about the appointment and click on Send button, an exception
-
How can I get rid of all the 'adobe' sources listed when importing in Lightroom?
How can I get these files to eject/disappear? I have tried searching them in finder and can't find them? Thank you.