Spliting the column Into multiple column diff secenario?
I have one table say tab_det having two columns
Tab_det
Tab_tablename varchar2(50),
Tab_tablename varchar2(50)
Select * from tab_det;
Tab_tablename ----> Tab_tablename
------------------ ------> ---------------------
Emp -------> empno,empname,dept
Emp_acct ------> empno,accno,accname,age
I want to split the each column name from <Tab_tablename > because it contains all the
Column name with comma separated and as a single value
I want to split the column name for each < Tab_tablename> Corresponding to
< Tab_tablename>
And I want to pass the column names dynamically and the output need to be written into the File
The Required Output In File
Empno empname dept
1 aaa cs
2 bbb ec
3 ccc ec
Empno accno accname age
1 12 aaa 34
2 13 bbb 36
3 14 ccc 38
4 14 ddd 40
Then do so.
Use INSTR to identify the locations of the commas and SUBSTR to separate the pieces.
We are not here to do your school work for you.
Similar Messages
-
How can I separate one column into multiple column?
How can I separate one column into multiple column?
This is what I have:
BUYER_ID ATTRIBUTE_NAME ATTRIBUTE_VALUE
0001 PHONE_NUMBER 555-555-0001
0001 EMAIL [email protected]
0001 CURRENCY USD
0002 PHONE_NUMBER 555-555-0002
0002 EMAIL [email protected]
0002 CURRENCY USD
0003 PHONE_NUMBER 555-555-0003
0003 EMAIL [email protected]
0003 CURRENCY CAD
This is what I would like to have:
BUYER_ID PHONE_NUMBER EMAIL CURRENCY
0001 555-555-0001 [email protected] USD
0002 555-555-0002 [email protected] USD
0003 555-555-0003 [email protected] CAD
Any help would be greatly appreciated.This is another solution. Suppose your actual table's name is test(which has the redundant data). create a table like this:
CREATE TABLE test2 (BUYER_ID number(10),PHONE_NUMBER varchar2(50),EMAIL varchar2(50),CURRENCY varchar2(50));
then you will type this procedure:
declare
phone_number_v varchar2(50);
EMAIL_v varchar2(50);
CURRENCY_v varchar2(50);
cursor my_test is select * from test;
begin
for my_test_curs in my_test loop
select ATTRIBUTE_VALUE INTO phone_number_v from test
where person_id=my_test_curs.person_id
and attribute_name ='PHONE_NUMBER';
select ATTRIBUTE_VALUE INTO EMAIL_v from test
where person_id=my_test_curs.person_id
and attribute_name ='EMAIL';
select ATTRIBUTE_VALUE INTO CURRENCY_v from test
where person_id=my_test_curs.person_id
and attribute_name ='CURRENCY';
INSERT INTO test2
VALUES (my_test_curs.person_id,phone_number_v,EMAIL_v,CURRENCY_v);
END LOOP;
END;
Then you will create your final table like this:
create table final_table as select * from test2 where 1=2;
After that write this code:
INSERT ALL
into final_table
SELECT DISTINCT(BUYER_ID),PHONE_NUMBER,EMAIL,CURRENCY
FROM TEST2;
If you have a huge amount of data in your original table this solution may take a long time to do what you need. -
To split a column into multiple columns
Hi,
I have column and i want to split it into three columns as shown below given inputs and required outputs. I have written this query to get P_1, and p_2 but dont know how to get p_3.
SELECT ADDRESS,SUBSTR(ADDRESS,1, INSTR(ADDRESS,' ')-1) P_1
,SUBSTR(ADDRESS, instr(address,' ',-1)+1) P_2
FROM TT
Input:
ADDRESS
1 AVENUE OF THE AMERICAS
2 NORTH CAROLINE STREET EAST
236 TURPENTINE ROAD COOPER CREEK
REQUIRED OUTPUT
P_1 P_2 P_3
1 AMERICAS AVENUE OF THE
2 EAST NORTH CAROLINE STREET
236 CREEK TURPENTINE ROAD COOPER
Thanks in advanceIf you're on 10g or 11g you can do something like this ...
SQL*Plus: Release 10.2.0.1.0 - Production on Tue Mar 4 21:18:07 2008
Connected to:
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
column p_1 format a3
column p_2 format a10
column p_3 format a30
with data as
select '1 AVENUE OF THE AMERICAS' as ADDRESS from dual union all
select '2 NORTH CAROLINE STREET EAST' as ADDRESS from dual union all
select '236 TURPENTINE ROAD COOPER CREEK' as ADDRESS from dual
select
regexp_replace( address, '^([^ ]+) (.+?) ([^ ]+)$', '\1' ) as p_1 ,
regexp_replace( address, '^([^ ]+) (.+?) ([^ ]+)$', '\3' ) as p_2 ,
regexp_replace( address, '^([^ ]+) (.+?) ([^ ]+)$', '\2' ) as p_3
from
data
P_1 P_2 P_3
1 AMERICAS AVENUE OF THE
2 EAST NORTH CAROLINE STREET
236 CREEK TURPENTINE ROAD COOPER
3 rows selected.
-- or try this shorter version --
with data as
select '1 AVENUE OF THE AMERICAS' as ADDRESS from dual union all
select '2 NORTH CAROLINE STREET EAST' as ADDRESS from dual union all
select '236 TURPENTINE ROAD COOPER CREEK' as ADDRESS from dual
select
regexp_replace( address, '^([^ ]+).*', '\1' ) as p_1 ,
regexp_replace( address, '.*?([^ ]+)$', '\1' ) as p_2 ,
regexp_replace( address, '^([^ ]+) (.+?) ([^ ]+)$', '\2' ) as p_3
from
data
P_1 P_2 P_3
1 AMERICAS AVENUE OF THE
2 EAST NORTH CAROLINE STREET
236 CREEK TURPENTINE ROAD COOPER
3 rows selected.See SQL Snippets: SQL Features Tutorials - Regular Expressions if you're unfamiliar with regular expressions.
If you can't / don't want to use regular expressions then you'll need to settle for a more boring approach like this one.
with data as
select '1 AVENUE OF THE AMERICAS' as ADDRESS from dual union all
select '2 NORTH CAROLINE STREET EAST' as ADDRESS from dual union all
select '236 TURPENTINE ROAD COOPER CREEK' as ADDRESS from dual
select
substr( address, 1, instr( address, ' ' ) - 1 ) as p_1 ,
substr( address, instr( address, ' ', - 1 ) + 1 ) as p_2 ,
substr
( address,
instr( address, ' ', + 1 ) + 1,
instr( address, ' ', - 1 ) - instr( address, ' ' ) - 1
) as p_3
from
data
P_1 P_2 P_3
1 AMERICAS AVENUE OF THE
2 EAST NORTH CAROLINE STREET
236 CREEK TURPENTINE ROAD COOPER--
Joe Fuda
SQL Snippets -
Split 1 column into multiple columns
Hi
How can we acheive this in Sql:
Col 1
abc def ghi jkl
convert to:
Col 1
Col 2
Col 3
Col 4
abc
def
ghi
jkl
Royal ThomasThe best approach is to NOT split them out into individual columns... It violates the 1st normal form...
Under first normal form, all occurrences of a record[sic] type must contain the same number of fields[sic].
First normal form excludes variable repeating fields[sic] and groups.
The better approach is to split them into rows, in their own table, with a foreign key reference back to the table you are pulling them away from.
If you check my 1st post you'll see that I split the string with a function. That same a function can be used to populate the new table.
Something along these lines...
IF OBJECT_ID('tempdb..#BadOldDesign') IS NOT NULL
DROP TABLE #BadOldDesign;
CREATE TABLE #BadOldDesign (
ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
ListOfCodes VARCHAR(100) NOT NULL
INSERT #BadOldDesign (ListOfCodes) VALUES
('abc htr tbj yfd hjk mth'),
('bbb hyt tbj vyk hjk htd'),
('vvv nud'),
('yyy hyn tbj bdr '),
('htr htf tbj yfd hjk mko'),
('kio bhn tbj bjd hjk'),
('byd loj tbj yfd hjk cds');
SELECT * FROM #BadOldDesign bod
IF OBJECT_ID('tempdb..#ShinyNewTable') IS NOT NULL
DROP TABLE #ShinyNewTable;
SELECT
bod.ID,
sc8.ItemNumber,
sc8.Item
INTO #ShinyNewTable
FROM
#BadOldDesign bod
CROSS APPLY dbo.SplitCSVToTable8K(bod.ListOfCodes, ' ') sc8;
ALTER TABLE #ShinyNewTable ALTER COLUMN id INT NOT NULL;
GO
ALTER TABLE #ShinyNewTable ALTER COLUMN ItemNumber INT NOT NULL;
GO
ALTER TABLE #ShinyNewTable ADD CONSTRAINT pk_ShinyNewTable PRIMARY KEY CLUSTERED (ID, ItemNumber);
SELECT * FROM #ShinyNewTable snt
The dbo.SplitCSVToTable8K function that I'm using can be found here... http://www.sqlservercentral.com/articles/Tally+Table/72993/
HTH,
Jason
Jason Long -
Convert 2 columns into multiple column table
Hi,
I have table with two columns. See below. I need to create a kind of matrix presentation of the table, so that values in row B become column titles, see second table. Amount of data is too big to create this manually.
TC1
Req2
TC2
Req1
TC3
Req0
TC4
Req1
TC5
Req2
TC6
Req3
TC7
Req4
TC8
Req5
TC9
Req6
TC10
Req7
TC11
Req8
TC12
Req9
TC13
Req10
TC14
Req11
TC15
Req12
TC16
Req7
TC17
Req8
TC18
Req3
TC19
Req13
TC20
Req14
TC21
Req15
TC22
Req16
Req1
Req2
Req3
Req4
Req5
Req6
Req7
Req8
TC1
X
TC2
X
TC3
X
TC4
X
TC5
TC6
X
X
TC7
X
TC8
TC9
X
X
TC10
TC11
X
TC12
X
TC13
X
X
TC14
X
X
TC15
X
TC16
TC17
X
TC18
X
TC19
TC20
X
X
x
TC21
X
TC22
X
Any suggestions how to proceed are greatly appreciated!
Question: Would Excel's PivotTable do the trick? No scripting needed?Hi and thanks for your reply! I added leading zeros. I tried the formula and the result looks like this from my first sample:
Req01
Req02
Req03
Req04
Req05
Req06
Req07
Req08
Req09
Req10
Req11
Req12
Req13
Req14
Req15
Req16
TC1
x
TC2
x
TC3
TC4
TC5
TC6
x
TC7
x
TC8
x
TC9
x
TC10
x
TC11
x
TC12
x
TC13
x
TC14
x
TC15
x
TC16
TC17
TC18
TC19
x
TC20
x
TC21
x
TC22
x
So row value remain empty if column value has earlier been met. Eg. TC17. Any ideas? -
Split single column into multiple column using sql /plsql
create table test (name varchar2(255);
insert into test values('DH RED 20 12/10 10 2 ');
insert into test values('PM STUD 20 15/10 20 29.55' );
insert into test values('LS MENTHOl FILTER ASC 18/70 60 240.66');
insert into test values('WINSTON WHITE CLASSIC 13 18/70 60 240.66');
My Output should be like as below in other table :
create table test_result (brand varchar2(255),packet varchar2(50),amount varchar2(25),total varchar2(25));
BRAND PACKET AMOUNT TOTAL
DH RED 20 12/10 10 2
PM STUD 20 15/10 20 29.55
LS MENTHOl FILTER ASC 18/70 60 240.66
WINSTON WHITE CLASSIC 13 18/70 60 240.66can you please help me to solve this issue
thanks in advance
Edited by: A on Apr 21, 2012 11:33 PM
Edited by: A on Apr 21, 2012 11:34 PM
Edited by: A on Apr 21, 2012 11:34 PMh4. # Database should be 10g. If version is below 10g query need to be modified as per string format.
h4. # Split string into two parts by '/'. First part contain brand + packet(1), Second part contain packet(2) + amount + total
h4. # Your brand name can be of any length.
String Format* : <Brand Name><space><packet(1)>/<packet(2)><space><amount><space><total>
SELECT name,
REGEXP_SUBSTR(first_part,'.+[[:space:]]',1,1) brand,
REGEXP_SUBSTR(first_part,'[^[:space:]]+/',1,1) || REGEXP_SUBSTR(second_part,'[^[:space:]]+[[:space:]]',1,1) packet,
REGEXP_SUBSTR(second_part,'[^[:space:]]+[[:space:]]',1,2) amount,
REGEXP_SUBSTR(second_part,'[^[:space:]]+$',1) total
FROM
(SELECT trim(name) name,
trim(substr(name,1, instr(name,'/'))) first_part,
trim(substr(name,instr(name,'/')+1)) second_part
FROM test )
{code} -
How can I Make one column into Multiple columns
Id
SCM-01-015
SCM-01-020
SFA-02-021
SFC-02-042
STB-03-035
STP-04-167
SVF-06-150
I want the output like this
Id 01 02 03 04 06
SCM-01-015 5
SCM-01-020 10
SFA-02-021 15
SFC-02-042 15
STB-03-035 20
STP-04-167 50
SVF-06-150 5
thank you in advanceHi,
801668 wrote:
Id
SCM-01-015
SCM-01-020
SFA-02-021
SFC-02-042
STB-03-035
STP-04-167
SVF-06-150
I want the output like this
Id 01 02 03 04 06
SCM-01-015 5
SCM-01-020 10
SFA-02-021 15
SFC-02-042 15
STB-03-035 20
STP-04-167 50
SVF-06-150 5
thank you in advanceWhenever you post formatted text (such as query output) on this site, type these 6 characters:
\(small letters only, inside curly brackets) before and after formatted text, to preserve spacing.
Do you want output something like this, which is from the scott.emp table?ENAME ANALYST CLERK MANAGER PRESIDENT SALESMAN
ALLEN 1600
JONES 2975
FORD 3000
CLARK 2450
MILLER 1300
SMITH 800
WARD 1250
MARTIN 1250
SCOTT 3000
TURNER 1500
ADAMS 1100
BLAKE 2850
KING 5000
JAMES 950
(ALLEN is a SALESMAN, JONES is a MANAGER, ..., JAMES is a CLERK.)
If so, do a pivot, somehting like this:SELECT ename
, MIN (CASE WHEN job = 'ANALYST' THEN sal END) AS analyst
, MIN (CASE WHEN job = 'CLERK' THEN sal END) AS clerk
, MIN (CASE WHEN job = 'MANAGER' THEN sal END) AS manager
, MIN (CASE WHEN job = 'PRESIDENT' THEN sal END) AS president
, MIN (CASE WHEN job = 'SALESMAN' THEN sal END) AS salesman
FROM scott.emp
GROUP BY ename
Always say which version of Oracle you're using.
The query above will work in Oracle 8.1 or higher, but starting in Oracle 11 there's a better way: SELECT ... PIVOT. -
Split column into multiple text and number columns
I'm trying to figure out how to split this column into multiple columns with power query. One column for the company name/person name, one for the address, one for the zip. Some of the addresses have a three or four digit code before the address, which
I would like in its own column too. It's the 170 on the lastname, firstname line. Does anyone have any pointers on this? I'm familiar with PQ advanced editor, but struggling with this one.
COMPANY INC. 195 MAIN ST MYCITY ST 12345
LASTNAME, FIRSTNAME 170 477 ANY STREET CIRCLE MYCITY ST 12345
Thanks for your help!HI Gil,
We have column with more than one numbers separated by space or comma or semicolon.
We need to add the row for each number by keeping all other column value same.
Here is a original table
Col1
Col2
Col3
A
B
11 22,33 44; 55
C
D
10 20
and expected output should be
Col1
Col2
Col3
A
B
11
A
B
22
A
B
33
A
B
44
A
B
55
C
D
10
C
D
20
Please let us know the best way to solve this... -
I want to convert a series of names into a table (in either numbers or pages). The list I have has a name and then an email address in brackets, followed by a 'yes' or a 'no'. I would like to separate the list into three columns - the first containing the name, the second containing the email address and the third containing the 'yes' or 'no'.
Can you help me ?The question that needs to be answered is what is separating the columns? Is it a single tab, one or more tabs, spaces, or what? Or is it the brackets that makes the separation between the three pieces of data?
If it is always a single tab, that makes it really easy. All you have to do is find/replace the brackets with nothing (as Wayne said)
If it might be multiple tabs, you can find/replace tab-tab with a single tab and repeat that a few times until no more double-tabs are found.
If it is one or multiple spaces, that might be difficult. I'll think about this one if this is what you have. I'll ignore this possiblility for now.
If it is the brackets separating the three pieces of data, you would Find/Replace the left bracket with a tab then do the same with the right bracket. -
Split one row into multiple columns
Hi,
Data in one CLOB column in a table storing with delimiter, ##~~##. Ex. ##~~##abc##~~##defgh##~~##ijklm##~~##nopqr (data starts with delimiter). Please help me to split the data into multiple rows like below and it should be in the same order.
abc
defgh
ijklm
nopqr
I am using Oracle 11g.
Thanks.Thanks Hoek for your response. Before posting my question in the forum, I tried similar query. It is working with one character as delimiter.
with test as (select 'ABC,DEF,GHI,JKL,MNO' str from dual )
select regexp_substr (str, '[^,]+', 1, rownum) split
from test
connect by level <= length (regexp_replace (str, '[^,]+')) + 1;
Above query is giving correct result by fetching 5 rows. I have modified the query like below...
with test as (select 'ABC,,,DEF,,,GHI,,,JKL,,,MNO' str from dual )
select regexp_substr (str, '[^,,,]+', 1, rownum) split
from test
connect by level <= length (regexp_replace (str, '[^,,,]+')) + 1;
Above query resulting 13 rows and last 8 rows are nulls. Number of null rows are increasing, if I increase number of characters in delimiter. Could you please tell me how to avoid those null rows.
Thanks. -
Split one column value and insert into multiple columns
hi
am new to plsql .
i want to split a characters from one column and insert into multiple columns
i tried used substr function the symbol ',' vary his place dynamically ,so i can't apply substr function.
for eg: before split
col1 :
col2 :
col3 :
col4 :
colu5: adsdf,fgrty,erfth,oiunth,okujt
after split
col1 :adsd
col2 :fgrty
col3 :erfth
col4 :oiunth
col5 : adsdf,fgrty,erfth,oiunth,okujt
can anyone help me
thanks
Edited by: 800324 on Dec 23, 2010 8:28 AM
Edited by: 800324 on Dec 23, 2010 8:36 AMHow about:
SQL> create table t
2 (col1 varchar2(30)
3 ,col2 varchar2(30)
4 ,col3 varchar2(30)
5 ,col4 varchar2(30)
6 ,col5 varchar2(30)
7 );
Table created.
SQL> insert into t (col5) values ('adsdf,fgrty,erfth,oiunth,okujt');
1 row created.
SQL> insert into t (col5) values ('x,y');
1 row created.
SQL> insert into t (col5) values ('a,b,c,d');
1 row created.
SQL> select * from t;
COL1 COL2 COL3 COL4 COL5
adsdf,fgrty,erfth,oiunth,okujt
x,y
a,b,c,d
3 rows selected.
SQL>
SQL> merge into t a
2 using ( with t1 as ( select col5||',' col5
3 from t
4 )
5 select substr(col5, 1, instr(col5, ',', 1, 1)-1) col1
6 , substr(col5, instr(col5, ',', 1, 1)+1, instr(col5, ',', 1, 2)- instr(col5, ',', 1, 1)-1) col2
7 , substr(col5, instr(col5, ',', 1, 2)+1, instr(col5, ',', 1, 3)- instr(col5, ',', 1, 2)-1) col3
8 , substr(col5, instr(col5, ',', 1, 3)+1, instr(col5, ',', 1, 4)- instr(col5, ',', 1, 3)-1) col4
9 , rtrim(col5, ',') col5
10 from t1
11 ) b
12 on ( a.col5 = b.col5 )
13 when matched then update set a.col1 = b.col1
14 , a.col2 = b.col2
15 , a.col3 = b.col3
16 , a.col4 = b.col4
17 when not matched then insert (a.col1) values (null);
3 rows merged.
SQL> select * from t;
COL1 COL2 COL3 COL4 COL5
adsdf fgrty erfth oiunth adsdf,fgrty,erfth,oiunth,okujt
x y x,y
a b c d a,b,c,d
3 rows selected.
SQL> Assuming you're on 9i... -
Split the result of one column to multiple columns
Hi Experts,
Could you please help me to split the result of below query into multiple columns:
EXEC master..xp_cmdshell 'wmic service where "Caption Like ''%sql%''" get Caption , StartName, state'
I needs result of this query something like below but in tabular format:
Caption
StartName
State
SQL Server Integration Services 11.0
NT Service\MsDtsServer110
Running
SQL Full-text Filter Daemon Launcher (MSSQLSERVER)
NT Service\MSSQLFDLauncher
Running
SQL Server (MSSQLSERVER)
NT Service\MSSQLSERVER
Running
SQL Server Analysis Services (MSSQLSERVER)
NT Service\MSSQLServerOLAPService
Running
--------------------------------- Devender BijaniaRefer below query,
DROP TABLE #TEMP
CREATE TABLE #TEMP(COLS NVARCHAR(300))
INSERT INTO #TEMP
EXEC master..xp_cmdshell 'wmic service where "Caption Like ''%sql%''" get Caption , StartName, state'
SELECT *,
PATINDEX('% %',COLS) C1,
LEFT(COLS, PATINDEX('% %',COLS)) Caption,
LTRIM(RIGHT(COLS,LEN(COLS)-PATINDEX('% %',COLS))) ServiceName,
PATINDEX('% %',LTRIM(RIGHT(COLS,LEN(COLS)-PATINDEX('% %',COLS)))) C2,
LTRIM(RIGHT(LTRIM(RIGHT(COLS,LEN(COLS)-PATINDEX('% %',COLS))), LEN(LTRIM(RIGHT(COLS,LEN(COLS)-PATINDEX('% %',COLS)))) - PATINDEX('% %',LTRIM(RIGHT(COLS,LEN(COLS)-PATINDEX('% %',COLS)))))) State
FROM #TEMP
WHERE COLS IS NOT NULL AND RTRIM(LEFT(COLS, PATINDEX('% %',COLS))) <> 'Caption'
Regards, RSingh -
Split flat file column data into multiple columns using ssis
Hi All, I need one help in SSIS.
I have a source file with column1, I want to split the column1 data into
multiple columns when there is a semicolon(';') and there is no specific
length between each semicolon,let say..
Column1:
John;Sam;Greg;David
And at destination we have 4 columns let say D1,D2,D3,D4
I want to map
John -> D1
Sam->D2
Greg->D3
David->D4
Please I need it ASAP
Thanks in Advance,
RH
sqlImports System
Imports System.Data
Imports System.Math
Imports Microsoft.SqlServer.Dts.Pipeline.Wrapper
Imports Microsoft.SqlServer.Dts.Runtime.Wrapper
Imports System.IO
Public Class ScriptMain
Inherits UserComponent
Private textReader As StreamReader
Private exportedAddressFile As String
Public Overrides Sub AcquireConnections(ByVal Transaction As Object)
Dim connMgr As IDTSConnectionManager90 = _
Me.Connections.Connection
exportedAddressFile = _
CType(connMgr.AcquireConnection(Nothing), String)
End Sub
Public Overrides Sub PreExecute()
MyBase.PreExecute()
textReader = New StreamReader(exportedAddressFile)
End Sub
Public Overrides Sub CreateNewOutputRows()
Dim nextLine As String
Dim columns As String()
Dim cols As String()
Dim delimiters As Char()
delimiters = ",".ToCharArray
nextLine = textReader.ReadLine
Do While nextLine IsNot Nothing
columns = nextLine.Split(delimiters)
With Output0Buffer
cols = columns(1).Split(";".ToCharArray)
.AddRow()
.ID = Convert.ToInt32(columns(0))
If cols.GetUpperBound(0) >= 0 Then
.Col1 = cols(0)
End If
If cols.GetUpperBound(0) >= 1 Then
.Col2 = cols(1)
End If
If cols.GetUpperBound(0) >= 2 Then
.Col3 = cols(2)
End If
If cols.GetUpperBound(0) >= 3 Then
.Col4 = cols(3)
End If
End With
nextLine = textReader.ReadLine
Loop
End Sub
Public Overrides Sub PostExecute()
MyBase.PostExecute()
textReader.Close()
End Sub
End Class
Put this code in ur script component. Before that add 5 columns to the script component output and name them as ID, col1, co2..,col4. ID is of data type int. Create a flat file destination and name it as connection and point it to the flat file as the source.
Im not sure whats the delimiter in ur flat file between the 2 columns. I have use a comma change it accordingly.
This is the output I get:
ID Col1
Col2 Col3
Col4
1 john
Greg David
Sam
2 tom
tony NULL
NULL
3 harry
NULL NULL
NULL -
Displaying single value (Record) into multiple columns
Hi All,
I want to display the single record into multiple columns. Please let me know How to achieve this..
Record:
Lvl Activity Acre
6 Week 4 (Same value to be displayed into 3 columns.)
REquired output:
lvl Activity PH1 PH2 PH3
6 Week 4 4 4
Thanks
Kaviuser533671 wrote:
Hi,
Thanks for immediate reply.
PH1, PH2, PH3, ... will go more columns based on parameter , what we are passing.An single SQL statement cannot have a dynamic number of columns based on the data itself. The projection (columns returned) have to be known before any data is fetched... and that includes some 'parameter' value.
{thread:id=2309172}
You can build a query dynamically, based on a parameter or even on the data, but 99 times out 100 people use dynamic queries where they are not needed.
Perhaps explain to us what you are really trying to achieve and why, and we could suggest some better way. -
To display comma separted value into multiple column
Hi,
I want to display value into multiple column like below
data is like this
col1
res_menaHome:MenaHome
res_menaHomeEmp:MenaHome Employee
res_MDSpecialSer:MD Special Services
res_Smart:Smart
now i want to display like
col1 col2
res_menaHome MenaHome
res_menaHomeEmp MenaHome Employee
res_MDSpecialSer MD Special Services
res_Smart Smart
Thanks in advance.You mean like this?
with q as (select 'res_menaHome:MenaHome' myString from dual)
select substr(myString, 1, instr(myString, ':') - 1) col1,
substr(myString, instr(myString, ':') + 1) col2
from q
COL1,COL2
res_menaHome,MenaHome
Maybe you are looking for
-
HELP! Getting a 4:3 project from a 16:9 sequence back to 4:3 sequence!
So here's the dilemma, I'm helping another user with a video project. The user created a whole movie out of 4:3 stills and an audio file, but arranged them in a 1280x720 (720p30) sequence. Now, of course, the images display with pillarboxing on both
-
How to replicate data from one page to another page
I have a five page document that has the same information on all five pages but each page goes to a different person. I want to fill-in the first page and have the information replicate to the other four. Any suggestion?
-
On digital readout, language is no longer in English and unreadable
I have a Officejet Pro 8500 printer that has freaked out and I can no longer read the digital messages therefore now I can't follow the instructions for the faxing, scanning, etc. The tech support was unable to help reset and suggested to buy a new
-
Error when attempting to allocate a pick wave move order
Hi All, We have a Sales order booked and pick released with Auto Allocate='No'.The lines on the sales order went to "Releases to warehouse" status and we need to do a move order. We Queried the move order and when checked found that the Allocated Qua
-
My iPhone 4S is not recognized by my computers. I have a Macbook at home and at work, and neither computers recognize the iPhone when I connect it. It doesn't even show up in Finder. I've tried different USB ports and USB cables, as well as restar