Data split into 2 rows
BW gurus,
Hope all are fine. I have an ODS (0FIA_DS13) feeding from two data sources.
They are 0FI_AA_12 and 80FIA_DS11( data mart of 0FIA_DS11).
I enhanced data source 0FI_AA_12 and added 2 extra char fields. After loading data , the data is not emerging into one row. Data coming from 0FI_AA_12 and 80FIA_DS11 coming in separate lines in the data target(0FIA_DS13). Before enhancement was OK. After enhancement this problem is happening.
Please advice.
Any advice/comments greatly appreciated.
Many thanks
Hi Manoj,
Based on ur scenario, u can ignore source system in reporting as it do not make any sense, if u do not map this field in to the Multiprovider, it wont make any problem. ( u can also make a variable on the source system and putting source sytem in filter in query, so that user can choose source if needed.)
As u are reporting based on business facts ( numerical values ), u just need to tick on source and facts, u need not to tick for both sources.
Let me make it more clear, u are clubbing business facts from both sources (ODS's), if u tick on both sources business facts will be summed up and reporting will be wrong, so u have to decide about perticular business facts for required source and map the fields ( identify ) in multiprovider.
Regards.
Similar Messages
-
Result may contain single string or comma separated need to split into rows
Hi, All... I've searched through the forums and found plenty on splitting comma separated into rows; though I'm struggling applying it to my situation. I have data that looks like the below where I need to split a value into multiple rows if it should be but the same field in the table may also contain a string that should not be separated (indicated by the "Array" field being 0 or 1)...
WITH t AS
(SELECT 1 as array, '"Banana", "Apple", "Pear"' as str FROM dual union all
SELECT 0, 'Fruit is delicious' FROM dual union all
SELECT 0, 'So are vegetables' FROM dual union all
SELECT 1, '"Bean", "Carrot", "Broccoli"' FROM dual union all
SELECT 1, '"Apple", "Banana"' FROM dual)I've looked through many of the connect_by posts on the forum and I haven't come across one that splits a field if it should be but doesn't if it should not be... may have missed it because there are plenty of these requests on the forum!
If you're feeling even more ambitious - the ultimate goal is to count the number of times a particular answer appears in an array - so notice the last portion of the data contains "Apple", "Banana"... the result would show:
RESULT
Banana 2
Apple 2
Pear 1
Bean 1
Carrot 1
Broccoli 1
Fruit is delicious
So are vegetablesI can always sort them later based on other fields in the table - but the result above would be my ultimate goal!
Any help is always appreciated. Thanks! 11gHi,
The examples you found should work for you. Just use a CASE expression to determine if str needs to be split or not, by looking at array.
Here's one way:
WITH got_part_cnt AS
SELECT array, str
, CASE
WHEN array = 0
THEN 1
-- ELSE 1 + REGEXP_COUNT (str, '", "') -- See note below
ELSE 1 + ( ( LENGTH (str)
- LENGTH (REPLACE (str, '", "'))
/ 4
END AS part_cnt
FROM t
, cntr AS
SELECT LEVEL AS n
FROM (
SELECT MAX (part_cnt) AS max_part_cnt
FROM got_part_cnt
CONNECT BY LEVEL <= max_part_cnt
, got_sub_str AS
SELECT CASE
WHEN p.array = 0
THEN p.str
ELSE REGEXP_SUBSTR ( p.str
, '[^"]+'
, 1
, (2 * c.n) - 1
END AS sub_str
FROM got_part_cnt p
JOIN cntr c ON c.n <= p.part_cnt
SELECT sub_str
, COUNT (*) AS cnt
FROM got_sub_str
GROUP BY sub_str
ORDER BY cnt DESC
, sub_str
{code}
The only database at hand right now is Oracle 10.2, which doesn't have REGEXP_COUNT. I had to use a complicated way of counting how many times '", "' occurs in str in order to test this in Oracle 10. Since you have Oracle 11, you can un-comment the line that uses REGEXP_COUNT in the first CASE expression, and remove the alternate ELSE clause (that is, the next 5 lines, up to END).
To make sure that this query is really paying attention to array, I added this row to the sample data:
{code}
SELECT 0, '"Bean", "Carrot", "Broccoli"' FROM dual union all
{code}
Even though str looks just like a delimited list, array=0 tells the query not to split it, so it produces these results:
{code}
SUB_STR CNT
Apple 2
Banana 2
"Bean", "Carrot", "Broccoli" 1
Bean 1
Broccoli 1
Carrot 1
Fruit is delicious 1
Pear 1
So are vegetables 1
{code} -
Data splitting into different rows
Hi
I have 2 columsn in table. Like this
Record ID Error Code
10 ABC,TRE,SDE,AQX,....
I want to change this format to like this
Record ID Error Code
10 ABC
10 TRE
10 SDE
10 AQX
If anybody knows please reply me.
ThanksIf you have more than one row in your table you have to do something like this, else the examples above will not work:
Based on the examples from Alex, see my previous link
SQL> -- generating sample data:
SQL> with t as (
2 select 10 rec_id, 'ABC,TRE,SDE,AQX' err_code from dual union
3 select 20 rec_id, 'BLA,YADDAH,STR' err_code from dual
4 )
5 --
6 -- actual query
7 --
8 select rec_id
9 , regexp_substr(err_code, '[^,]+', 1, rn) err_code
10 from t
11 cross join ( select rownum rn
12 from ( select max(length(regexp_replace(err_code, '[^,]+'))) + 1 mx
13 from t
14 )
15 connect by level <= mx
16 )
17 where regexp_substr(err_code, '[^,]+', 1, rn) is not null
18 order by rec_id;
REC_ID ERR_CODE
10 ABC
10 SDE
10 TRE
10 AQX
20 STR
20 BLA
20 YADDAH
7 rows selected. -
Please help with: A date split into 3 Combo Boxes ....
Can someone help me with this Please?
I have a date for a Date of Birth i.e. dd/MM/yyyy
I need to split it up an place it into 3 combo boxes i.e. Day Combo, Month Combo and Year Combo.
This is the code I have to set the combo boxes, now I need to bring it back into the combo boxes.
can someone help me with the code as I need to have this finish on friday and I am running out of time. I just dont know what to do PLEASE SOMEONE HELP...
Thanks
Craig
// List days
private void DayOfTheMonth(int highNumber,JComboBox comboBox){
comboBox.addItem(" ");
for (int index = 1; index < highNumber; index++) {
comboBox.addItem(String.valueOf(index));
private void DaySpecificComboBox()
DayOfTheMonth( 32, DayjComboBox);
// List Months
private void Month(){
MonthjComboBox.addItem("");
MonthjComboBox.addItem("January");
MonthjComboBox.addItem("February");
MonthjComboBox.addItem("March");
MonthjComboBox.addItem("April");
MonthjComboBox.addItem("May");
MonthjComboBox.addItem("June");
MonthjComboBox.addItem("July");
MonthjComboBox.addItem("August");
MonthjComboBox.addItem("September");
MonthjComboBox.addItem("October");
MonthjComboBox.addItem("November");
MonthjComboBox.addItem("December");
//List Years
private void Year(int highNumber,JComboBox comboBox){
comboBox.addItem(" ");
for (int index = 2002; index > highNumber; index--) {
comboBox.addItem(String.valueOf(index));
private void YearSpecificComboBox()
Year( 1900, YearjComboBox);
private String StringFromDateFields(){
int month =1;
if (MonthjComboBox.getSelectedItem().equals(JANUARY))
month = 1;
else
if (MonthjComboBox.getSelectedItem().equals(FEBRUARY))
month = 2;
else
if (MonthjComboBox.getSelectedItem().equals(MARCH))
month = 3;
else
if (MonthjComboBox.getSelectedItem().equals(APRIL))
month = 4;
else
if (MonthjComboBox.getSelectedItem().equals(MAY))
month = 5;
else
if (MonthjComboBox.getSelectedItem().equals(JUNE))
month = 6;
else
if (MonthjComboBox.getSelectedItem().equals(JULY))
month = 7;
else
if (MonthjComboBox.getSelectedItem().equals(AUGUST))
month = 8;
else
if (MonthjComboBox.getSelectedItem().equals(SEPTEMBER))
month = 9;
else
if (MonthjComboBox.getSelectedItem().equals(OCTOBER))
month = 10;
else
if (MonthjComboBox.getSelectedItem().equals(NOVEMBER))
month = 11;
else
if (MonthjComboBox.getSelectedItem().equals(DECEMBER))
month = 12;
String
DOB = DayjComboBox.getSelectedItem()+"/"+String.valueOf(month)+"/"+YearjComboBox.getSelectedItem();
return DOB;Thanks for your time.
I could not get that to work ??
I have come up with this code whitch seams to work. Thought you may like to see it
String dobxml = xmlDoc.getValueOf(clientInfo, "DOB");
String dob = dobxml.replace('/', ' ');
System.out.println(dob);
StringTokenizer tokenizer = new StringTokenizer(dob);
String day = tokenizer.nextToken();
String month = tokenizer.nextToken();
String year = tokenizer.nextToken();
System.out.println(dob);
DayjComboBox.setSelectedItem(day);
MonthjComboBox.setSelectedIndex(Integer.parseInt(month));
YearjComboBox.setSelectedItem(year);ps thankyou
Craig -
Httpwebrequest POST with data splits into two frames
Hi,
I'm working with a code that should send (xml) data to a web site using post method to login.
I have a web page that does exactly that with ajax, and I'm been comparing the post from my code with the post of the webpage with wireshark.
When the post is made from the web page, everything works OK (the login in successfull) and Whireshark shows one line with the full POST and the answer of the site.
When I execute my code, the whireshark shows one line masrked as "PDU reassembly", and then the POST, as if was splitted in two with the connection and cookie information first and the data later.
The problem is that the web site, receives the first frame and as it's not complete, it rejects the login. Then recieves just the data and then discards it.
I've tried different things that I've found in forums, but I can't make it work in one frame. As soon as I add the data part of the post, it is sent splitted.
I attach the code below and a snapshot of the two wireshark captures.
Imports System.Net
Imports System.Text
Imports System.IO
Module Module1
Sub Main()
Dim logincookie As System.Net.Cookie
logincookie = New System.Net.Cookie("RMASESSID", "1234")
logincookie.Domain = "192.168.0.88"
logincookie.Path = "/"
logincookie.HttpOnly = True
Dim postData As String
postData = "<login><usuario>web</usuario><clave>web</clave></login>"
Dim CookiesContainer As System.Net.CookieContainer
CookiesContainer = New System.Net.CookieContainer()
'CookiesContainer.Add(logincookie)
Dim encoding As System.Text.UTF8Encoding
encoding = New System.Text.UTF8Encoding
Dim byteData As System.Byte()
byteData = encoding.GetBytes(postData)
Dim postReq As System.Net.HttpWebRequest
Dim postreqstream As System.IO.Stream
'postReq.CookieContainer = New System.Net.CookieContainer();
Dim DomUri As System.Uri
DomUri = New System.Uri("http://192.168.0.78")
' Genero el POST
postReq = System.Net.WebRequest.Create("http://192.168.0.78:8888/login0001.html")
postReq.CookieContainer = CookiesContainer
postReq.CookieContainer.SetCookies(DomUri, "RMASESSID")
postReq.Method = "POST"
postReq.KeepAlive = True
postReq.ContentType = "application/x-www-form-urlencoded"
postReq.UserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; ru; rv:1.9.2.3) Gecko/20100401 Firefox/4.0 (.NET CLR 3.5.30729)"
postReq.ContentLength = byteData.Length
' Envío el pedido del POST
postReq.SendChunked = False
postreqstream = postReq.GetRequestStream()
postreqstream.Write(byteData, 0, byteData.Length)
postreqstream.Close()
Dim postresponse As System.Net.HttpWebResponse
postresponse = postReq.GetResponse()
CookiesContainer.Add(postresponse.Cookies)
' logincookie = tempCookies;
Dim postreqreader As System.IO.StreamReader
postreqreader = New System.IO.StreamReader(postresponse.GetResponseStream())
Dim thepage As String
thepage = postreqreader.ReadToEnd()
End Sub
End Module
I couldn't attach the images from wireshark, I will send when the account is verified.
Thanks.
DiegoThat's a tough one... I can only guess that maybe it has something to do with the configuration of the request... maybe a property value that needs to be changed or header that needs to be added?
I wonder though, if you are hosting this website, can you edit it? Would it be possible to add a proper web service of some sort to the website so that your Windows Forms application had a proper web reference to consume?
Reed Kimble - "When you do things right, people won't be sure you've done anything at all" -
Parse String, split into rows
I have a report who has the following output:
MODEL PO No RR No RR Date, PartNo Part Description, Qty Received Lot No DR No. DR Date
QB3-DLX 150 100455 3/16/2011 657712S400 ROD HOOD SUPPORT 72 252-36,253-36 2345 3/15/2011
based on the Lot No column result would be:
MODEL PO No RR No RR Date PartNo Part Description Qty Received Lot No DR No. DR Date
QB3-DLX 150 100455 3/16/2011 657712S400 ROD HOOD SUPPORT 36 252-36 2345 3/15/2011
QB3-DLX 150 100455 3/16/2011 657712S400 ROD HOOD SUPPORT 36 253-36 2345 3/15/2011
How will I parse the Lot No column and have the following result displayed as above?
Thank you in advance.Hi,
You may do the opposite: i.e. from 2 lines to one. It will be extremely difficult or not possible to meet your above need.
Thanks,
Gordon -
Field with comma separated values to be split into Rows using a Query
Thanks for the Reply.. I also have to Decode each of the spilt values with some text..
replace(disc_topics,',',chr(10)) A from XYZ
Disc_topics values are '01,02,03,04,05'
this has to be done in SQL
01 Test1
02 Test2
03 Test3
04 Test4select replace( replace( replace( replace( '#' || '01,02,03,04,05,10,11', ',', ',#'), '#0','#'),'#','Test'),',',chr(10)) A from XYZ
-
Need to split data from one row into a new row redux
Hi folks,
I asked this question about eight months ago (see thread https://discussions.apple.com/message/23961353#23961353) and got an excellent response from forum regular Wayne Contello. However, I need to perform this operation again and when I attempted it recently, I am now greeted with a yellow warning triangle. Clicking it shows "This formula can’t reference its own cell, or depend on another formula that references this cell."
What I'm trying to do is the following:
I have an excel file that keeps track of members of a social group. The file places each member "unit" on a single row. The unit can be a single person or a couple. Columns are labeled "First1" "Last1" "Hometown1" "B-day1" while the second member of the unit is identified in columns like "First2" "Last2" etc.
What I'd like to do is duplicate those rows with two people (which I'll do by hand) but have a way of deleting the "xxxx2" data from one row and the "xxxx1" data from the duplicate row.
Wayne's illustrated solution was to create a blank sheet and enter the following formula in cell A2:
=OFFSET(Input Data::$A$2, INT((ROW()−2)÷2), COLUMN()−1+IF(MOD(ROW()−2, 2)=0, 0, 4)), which apparently worked fine for me last year but now is sending up an error flag. When I look at the formula, there is no clue except that which I quoted above.
Can anyone (or hopefully Wayne) take a second look at this and help me out? I can't imagine that it's a problem with using the newer version of Numbers, but who knows? I'm using version 3.2 (1861), which is the "new" Numbers.
Any help would really be appreciated.
Thanks!
-TodHi Tod,
The error message "This formula can’t reference its own cell, or depend on another formula that references this cell." may be because your table may be different from the one you were using for Wayne's solution. Numbers has Header Rows, Footer Rows and Header Columns. Such Headers in tables exclude themselves from formulas. Excel does not recognise them as headers. What table are you using now?
A screen shot of (the top left portion of) your table or a description of what you see under Menu > Table will help.
Regards,
Ian. -
How to display the data in PDF format : problem is splitting into 2 lines
Hi ,
I developed one report which downloads the data into PDF format and saved in C drive but my problem is
in my program : Line size of the report is 255 in PDF it is splitting into 2 lines. it has to show in a single line. how to do it. how to reduce the width of the output? i am sending my code below. anybody can suggest me how to do it. if possible please send me the code.
my code:
report zmaheedhar.
maheedhar-start
TABLES : vbak.
parameters : p_vbeln type vbak-vbeln.
data : begin of itab occurs 0,
vbeln type vbak-vbeln,
ERDAT type vbak-erdat,
ERZET type vbak-erzet,
ERNAM type vbak-ernam,
ANGDT type vbak-angdt,
BNDDT type vbak-bnddt,
AUDAT type vbak-audat,
VBTYP type vbak-vbtyp,
TRVOG type vbak-trvog,
AUART type vbak-auart,
AUGRU type vbak-augru,
GWLDT type vbak-gwldt,
SUBMI type vbak-submi,
LIFSK type vbak-lifsk,
FAKSK type vbak-faksk,
NETWR type vbak-netwr,
WAERK type vbak-waerk,
VKORG type vbak-vkorg,
end of itab.
maheedhar-end
DATA: pripar TYPE pri_params,
arcpar TYPE arc_params,
lay TYPE pri_params-paart,
lines TYPE pri_params-linct,
rows TYPE pri_params-linsz.
DATA: val(1), val1(1).
*---> Local Printer Name defined in SAP, Change NHREMOTE to your local printer
DATA: dest TYPE pri_params-pdest VALUE 'ZNUL'.
DATA: name TYPE pri_params-plist VALUE 'Testing'.
DATA: i_pdf TYPE STANDARD TABLE OF tline.
DATA: spono TYPE tsp01-rqident.
maheedhar-start
top-of-page.
write: 'Sales Document' , 'C Date', 'Entry time', 'Created By','Quotation date',
'Date','Document Date','SD document category','Transaction group','Sales Document Type',
'Order reason'.
start-OF-SELECTION.
select vbeln ERDAT ERZET ERNAM ANGDT BNDDT AUDAT
VBTYP TRVOG AUART AUGRU GWLDT SUBMI LIFSK
FAKSK NETWR WAERK VKORG from vbak
into table itab
where vbeln = p_vbeln.
maheedhar-end
--- Retreive local printer details
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
destination = dest
no_dialog = 'X'
immediately = ' '
IMPORTING
out_archive_parameters = arcpar
out_parameters = pripar
valid = val
valid_for_spool_creation = val1
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF sy-subrc NE 0.
MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
ENDIF.
*-- Set Spool printer details w.r.t local printer
pripar-prdsn = 'DSN'.
CALL FUNCTION 'GET_PRINT_PARAMETERS'
EXPORTING
in_archive_parameters = arcpar
in_parameters = pripar
no_dialog = 'X'
list_name = name
IMPORTING
out_archive_parameters = arcpar
out_parameters = pripar
valid = val
valid_for_spool_creation = val1
EXCEPTIONS
archive_info_not_found = 1
invalid_print_params = 2
invalid_archive_params = 3
OTHERS = 4.
IF sy-subrc EQ 0.
---> Triggers the spool creation in the sense all the write statements from hereon will be written to spool instead of screen
NEW-PAGE PRINT ON
NEW-SECTION
PARAMETERS pripar
ARCHIVE PARAMETERS arcpar
NO DIALOG.
ELSE.
WRITE:/ 'Unable to create spool'.
ENDIF.
*--- Output statements
*WRITE:/ 'First Line', 'mahee','lklk','kikik','lokiuj','fffff','kijuyh','fgfgfgfg','gtgtgtgtgtgtgtgtggggggggggggggggggggggggggggggg'.
*WRITE:/ 'Second Line'.
LOOP at itab.
write: itab-vbeln,
itab-ERDAT,
itab-ERZET,
itab-ERNAM,
itab-ANGDT,
itab-BNDDT,
itab-AUDAT,
itab-VBTYP.
ENDLOOP.
"---> Close spool
NEW-PAGE PRINT OFF.
spono = sy-spono.
Convert ABAP Spool to PDF
CALL FUNCTION 'CONVERT_ABAPSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = spono
no_dialog = 'X'
TABLES
pdf = i_pdf
EXCEPTIONS
err_no_abap_spooljob = 1
err_no_spooljob = 2
err_no_permission = 3
err_conv_not_possible = 4
err_bad_destdevice = 5
user_cancelled = 6
err_spoolerror = 7
err_temseerror = 8
err_btcjob_open_failed = 9
err_btcjob_submit_failed = 10
err_btcjob_close_failed = 11
OTHERS = 12.
Download PDF contents to presentation server
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'c:\test.pdf'
filetype = 'BIN'
TABLES
data_tab = i_pdf
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.
thanks,
maheedharhi tripat,
actual problem is what u said it is decreased the wiidht of the output.
now the output is:
Sales Document C Date Entry time Created By Quotation date Date Document Date
SD document category Transaction group Sales Document Type Order reason
62741 07/29/1996 11:54:38 DARLENE 00/00/0000 00/00/0000 07/29/1996 C
actual output is:
output should come in a single line. it is splitting into 2 lines.
thanks,
maheedhar -
Query to split one row to multiple based on date range
Hi,
I need to split single row into multple based on date range defined in a column, start_dt and end_dt
I have a data
ID From date End_dt measure
1 2013-12-01 2013-12-03 1
1 2013-12-04 2013-12-06 2
2 2013-12-01 2013-12-02 11
3 2013-12-03 2013-12-04 22
I required output as
ID Date measure
1 2013-12-01 1
1 2013-12-02 1
1 2013-12-03 1
1 2013-12-04 2
1 2013-12-05 2
1 2013-12-06 2
2 2013-12-01 11
2 2013-12-02 11
3 2013-12-03 22
3 2013-12-04 22
Please provide me sq, query for the same
Amit
Please mark as answer if helpful
http://fascinatingsql.wordpress.com/Have a calendar table for example and then probably using UNION ALL from date and stat date JOIN the Calendar table
SELECT ID,From date FROM tbl
union all
SELECT ID,End_dt FROM tbl
with tmp(plant_date) as
select cast('20130101' as datetime)
union all
select plant_date + 1
from tmp
where plant_date < '20131231'
select*
from tmp
option (maxrecursion 0)
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Split single row in multiple rows based on date range
I need sql script that can split single row in multiple rows based on start date and end date column in table.
Thank youI agree to your suggestion of having a dates table permanently in the database. Thats how we also do for most of our projects as well
But in most projects the ownership of table creation etc lies with the client as they will be the DBAs and will be design approval authorities. What I've seen is the fact that though
many of them are in favour of having calendar table they dont generally prefer having a permanent table for numbers in the db. The best that they would agree is for creating a UDF which will have
tally table functionality built into it based on a number range and can be used in cases where we need to multiply records as above.
Wherever we have the freedom of doing design then I would also prefer creating it as a permanent table with required indexes as you suggested.
>> many of them are in favour of having calendar table they dont generally prefer having a permanent table
Those people do not understand about database and are not DBAs :-)
It is our job to tell them what is right or wrong.
** This is a real story! I had a client several years back, who was the CEO of a software company.
He use the query:
select * from table_name
In order to get the last ID!
The table_name was actually a view that took data from several tables, and the main table that he wanted to get the ID included several string columns, with lot of data!
he actually pulled all this data to the application, just to get the lat ID in a specific table!
It is our job as Consultants or DBAs to fix's his misunderstanding :-)
Ronen Ariely
[Personal Site] [Blog] [Facebook] -
How to split columns into rows
Hi All,
Below is my table structure:=
SQL> create table split(id number,value varchar2(200));
Table created.
SQL> insert into split values(1,'X,Y,Z');
1 row created.
SQL> insert into split values(2,'A,B,C');
1 row created.
SQL> commit;
Commit complete.
Expected Output
ID Value
1 X
1 Y
1 Z
2 A
2 B
3 C
I know the feature of converting rows into columns by listagg in Oracle 11g, but is there any feature to convert rows into columns based on a delemiter..."," in my case.
Please help....
Thanks
Arijit>
is there any feature to convert rows into columns based on a delemiter
>
Here is one way
VAR csv VARCHAR2(100)EXEC :csv := 'abc,de,fg,hij,klmn,o,pq,rst,uvw,xyz';
The query:
WITH data AS( SELECT SUBSTR(csv, INSTR(csv,',',1,LEVEL)+1, INSTR(csv,',',1,LEVEL+1) - INSTR(csv,',',1,LEVEL)-1 ) token FROM ( SELECT ','||:csv||',' csv FROM SYS.DUAL ) CONNECT BY LEVEL < LENGTH(:csv)-LENGTH(REPLACE(:csv,',',''))+2 )SELECT token FROM data;See http://projectwownow.blogspot.com/2010/02/oracle-convert-csv-string-into-rows.html -
Hi!
I need to split this row into 2 rows. The key is the flight_leg_id.
SELECT *
FROM favailability a, favailability b
WHERE a.from_city = b.to_city
AND a.to_city = b.from_city
AND a.from_city = 'Zurich'
AND a.service_class = 'Economy'
AND a.fare_type = 'Economy Flex'
AND a.flight_date = '01.10.09'
AND b.from_city = 'London'
AND b.service_class = 'Economy'
AND b.fare_type = 'Economy Flex'
AND b.flight_date = '11.10.09';
FLIGHT_LEG_ID CARRIER_CODE FLIGHT_NO FROM_CITY ORIGIN DEPT_TIME TO_CITY DESTINATION ARR_TIME FLIGHT_DATE AIRCRAFT_TYPE BOOKING_CLASS SERVICE_CLASS NUM_OF_SEATS SEATS_OCC CHECKED_BAG FARE_BASIS FARE_TYPE CURRENCY RT_NET_FARE OW_FARE TAX SURCHARGES FARE_TOTAL FLIGHT_LEG_ID CARRIER_CODE FLIGHT_NO FROM_CITY ORIGIN DEPT_TIME TO_CITY DESTINATION ARR_TIME FLIGHT_DATE AIRCRAFT_TYPE BOOKING_CLASS SERVICE_CLASS NUM_OF_SEATS SEATS_OCC CHECKED_BAG FARE_BASIS FARE_TYPE CURRENCY RT_NET_FARE OW_FARE TAX SURCHARGES FARE_TOTAL
3 LX 450 Zurich ZRH 07:00 London LCY 07:35 01.10.09 AVRO RJ100 B Economy 57 20 kg LXB Economy Flex EUR 708 30,01 21,24 759,34 4 LX 345 London LHR 06:00 Zurich ZRH 08:40 11.10.09 Airbus A320 B Economy 72 20 kg LXB Economy Flex EUR 707 30,01 35,24 772,25
1 rows selectedHow can I do this?BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Prod
PL/SQL Release 10.2.0.1.0 - Production
CORE 10.2.0.1.0 Production
TNS for 32-bit Windows: Version 10.2.0.1.0 - Production
NLSRTL Version 10.2.0.1.0 - Production
5 rows selected
CREATE TABLE "TEST"."FAVAILABILITY"
( "FLIGHT_LEG_ID" NUMBER NOT NULL ENABLE,
"CARRIER_CODE" VARCHAR2(3 BYTE) NOT NULL ENABLE,
"FLIGHT_NO" NUMBER(4,0) NOT NULL ENABLE,
"FROM_CITY" VARCHAR2(70 BYTE) NOT NULL ENABLE,
"ORIGIN" VARCHAR2(3 BYTE) NOT NULL ENABLE,
"DEPT_TIME" VARCHAR2(6 BYTE) NOT NULL ENABLE,
"TO_CITY" VARCHAR2(70 BYTE) NOT NULL ENABLE,
"DESTINATION" VARCHAR2(6 BYTE) NOT NULL ENABLE,
"ARR_TIME" VARCHAR2(6 BYTE) NOT NULL ENABLE,
"FLIGHT_DATE" DATE NOT NULL ENABLE,
"AIRCRAFT_TYPE" VARCHAR2(40 BYTE) NOT NULL ENABLE,
"BOOKING_CLASS" CHAR(1 BYTE) NOT NULL ENABLE,
"SERVICE_CLASS" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"NUM_OF_SEATS" NUMBER(3,0) NOT NULL ENABLE,
"SEATS_OCC" NUMBER(3,0),
"CHECKED_BAG" VARCHAR2(20 BYTE),
"FARE_BASIS" VARCHAR2(8 BYTE) NOT NULL ENABLE,
"FARE_TYPE" VARCHAR2(30 BYTE) NOT NULL ENABLE,
"CURRENCY" VARCHAR2(3 BYTE) NOT NULL ENABLE,
"RT_NET_FARE" NUMBER(6,2) NOT NULL ENABLE,
"OW_FARE" NUMBER(5,2),
"TAX" NUMBER(5,2) NOT NULL ENABLE,
"SURCHARGES" NUMBER(4,2),
"FARE_TOTAL" NUMBER(6,2) NOT NULL ENABLE,
CONSTRAINT "FAVAILABILITY_PK" PRIMARY KEY ("FLIGHT_LEG_ID", "CARRIER_CODE", "FLIGHT_NO", "ORIGIN", "DEPT_TIME", "DESTINATION", "FLIGHT_DATE", "BOOKING_CLASS", "SERVICE_CLASS", "FARE_BASIS", "FARE_TYPE")
USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ENABLE
) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255 NOCOMPRESS LOGGING
STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
TABLESPACE "USERS" ;
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (5,'LH',4732,'Frankfurt','FRA','15:15','London','LHR','15:50',to_timestamp('01.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','P','Economy',190,null,null,'LHP','Economy Basic','EUR',252,null,124.64,15,376.64);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (5,'LH',4732,'Frankfurt','FRA','15:15','London','LHR','15:50',to_timestamp('03.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','P','Economy',190,null,null,'LHP','Economy Basic','EUR',252,null,124.64,15,376.64);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (5,'LH',4732,'Frankfurt','FRA','15:15','London','LHR','15:50',to_timestamp('04.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','P','Economy',190,null,null,'LHP','Economy Basic','EUR',252,null,124.64,15,376.64);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (5,'LH',4732,'Frankfurt','FRA','15:15','London','LHR','15:50',to_timestamp('05.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','P','Economy',190,null,null,'LHP','Economy Basic','EUR',252,null,124.64,15,376.64);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (5,'LH',4732,'Frankfurt','FRA','15:15','London','LHR','15:50',to_timestamp('06.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','P','Economy',190,null,null,'LHP','Economy Basic','EUR',252,null,124.64,15,376.64);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (5,'LH',4732,'Frankfurt','FRA','15:15','London','LHR','15:50',to_timestamp('07.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','P','Economy',190,null,null,'LHP','Economy Basic','EUR',252,null,124.64,15,376.64);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (6,'LH',4727,'London','LHR','11:50','Frankfurt','FRA','14:20',to_timestamp('20.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','G','Economy',190,null,null,'LHG','Economy Basic','EUR',252,null,0,0,252);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (6,'LH',4727,'London','LHR','11:50','Frankfurt','FRA','14:20',to_timestamp('21.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','G','Economy',190,null,null,'LHG','Economy Basic','EUR',252,null,0,0,252);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (6,'LH',4727,'London','LHR','11:50','Frankfurt','FRA','14:20',to_timestamp('22.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','G','Economy',190,null,null,'LHG','Economy Basic','EUR',252,null,0,0,252);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (6,'LH',4727,'London','LHR','11:50','Frankfurt','FRA','14:20',to_timestamp('23.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','G','Economy',190,null,null,'LHG','Economy Basic','EUR',252,null,0,0,252);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (6,'LH',4727,'London','LHR','11:50','Frankfurt','FRA','14:20',to_timestamp('24.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','G','Economy',190,null,null,'LHG','Economy Basic','EUR',252,null,0,0,252);
Insert into FAVAILABILITY (FLIGHT_LEG_ID,CARRIER_CODE,FLIGHT_NO,FROM_CITY,ORIGIN,DEPT_TIME,TO_CITY,DESTINATION,ARR_TIME,FLIGHT_DATE,AIRCRAFT_TYPE,BOOKING_CLASS,SERVICE_CLASS,NUM_OF_SEATS,SEATS_OCC,CHECKED_BAG,FARE_BASIS,FARE_TYPE,CURRENCY,RT_NET_FARE,OW_FARE,TAX,SURCHARGES,FARE_TOTAL) values (6,'LH',4727,'London','LHR','11:50','Frankfurt','FRA','14:20',to_timestamp('25.10.09','DD.MM.RR HH24:MI:SSXFF'),'Airbus A321-131','G','Economy',190,null,null,'LHG','Economy Basic','EUR',252,null,0,0,252);Edited by: user545194 on 30-Sep-2009 06:29 -
Problem in displaying the data of columns into rows in sap script
hi,
i am working on a sap script and i have to display the dat which is displayed in column into rows but it is not displaying it properly.
eg, C
12.1
Si
5.5
it is displaying the data right now like this but i want to display the data like this:-
eg, C Si
12.1 5.5
plzzprovide me guidelines how to solve this problem.hi,
i am using this code to display the data:-
plzz provide me guidelines where i am getting wrong?
TOPparCOMPONENT DESP,,,,,, INS. LOT #, , , , , , MIC,,,,,,,,,, MIC VALUEparENDTOPparFINAL
PROTECT
IF &I_FINAL-PRUEFLOS& NE '000000000000'
&I_FINAL-MAKTX(23)&&i_final-prueflos(12Z)&
&I_FINAL-kurztext(25)&
&I_FINAL-original_input(8)&
ELSE
&I_FINAL-MAKTX(23)&
&I_FINAL-kurztext(25)&
&I_FINAL-original_input(8)&
ENDIF
ENDPROTECT
ITEMHEAD
POSITION WINDOW
SIZE WIDTH +0 . 4 CH HEIGHT +1 LN
BOX FRAME 10 TW
BOX HEIGHT '1.35' LN INTENSITY 20
IF &PAGE& = '1'
BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '43' LN FRAME '10' TW
For horizontal line at top
BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
COLUMN LINES...
END OF COLUMN LINES...
BOX XPOS '0' CH YPOS '43' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '43' LN FRAME '10'TW
ELSE
COLUMN LINES...
END OF COLUMN LINES...
BOX XPOS '0' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '0' CM WIDTH '75' CH HEIGHT '0' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '0' CM WIDTH '45' CM HEIGHT '0' LN FRAME '10' TW
BOX XPOS '20' CH YPOS '0' CM WIDTH '0' CM HEIGHT '47' LN FRAME '10' TW
BOX XPOS '0' CH YPOS '47' LN WIDTH '75' CH HEIGHT '0' LN FRAME '10'TW
BOX XPOS '75' CH YPOS '0' LN WIDTH '0' CH HEIGHT '47' LN FRAME '10'TW
ENDIF
LINEFEED
NEWPAGE
NEW-PAGE
provide me guidelines to solve this problem.
Edited by: ricx .s on Mar 13, 2009 5:58 AM -
Alv output splitting into two rows when converting into excel sheet.
Hi frends,
I have alv report with 60 fields . The report output is coming currently . But when i am exporting into excel sheet from the option local file--> speadsheet each row is splitting into two rows including header in excel sheet.
Please provide your valuable suggestions to avoid this.
Regards,
Ramu .
Edited by: Ramu.K on Sep 8, 2009 5:59 PMHi,
Please use the grid option and with the Spreadsheet button (CntrShiftF7). Do "Save as" and save it as excel. It should work.
Regards,
Pradyumna
Maybe you are looking for
-
Logical sql in log file.
Can someone please tell me how to see the complete sql query in the log file. If I run the same query the sql is not being produced I looked in the server log file and also manage sessions log file. It just says all columns from 'Subject Area'. I wan
-
IN SE78 : WHILE UPLOADING THE TIF FILE I AM GETTING THE ERROR
Hi , While uploading the drawing in se78 . iam getting the errror "erroneous tif formate" . PLz help me to upload the tif file thro se78. even i removed the compression check box ,. Thanks, Rani
-
How to control HP8350B with HP83592A and HP8757A
I want to control HP8350B with plug in HP83592A and HP8757A by NI GPIB,using Labview language and print out HP8757A screen chart to printer, but when I sent command to HP8757A according to HP8350B manual ,such as "PT19",the instrument has no response
-
Hello, I have a iPhone 5 that constantly switches back and for between 1.0Mb/s and 54.0Mb/s. Is this any indication that the wifi is faulty on this phone? There are two other devices on the same ap that are totally fine and maintain a constant rate.
-
How to cancel the Adobe ExportPDF Annual
Just bought the membership, then found out it's not what I want. So, how I can cancel it?