PL/SQL :: Convert Rows To Single Column

Dec 11, 2012

I have a table where i want the output to be a single column

ex: select from t1;*
query output_

rownum col_1
1     8217
2     6037
3     5368
4     5543
5     5232

i would like the result to be : *8217,6037,5368,5543,5232*

i did look on the web but can't find a solution that is easily understood.

View 9 Replies


ADVERTISEMENT

SQL & PL/SQL :: How To Convert Single Row Into Multiple Rows

Feb 28, 2012

CREATE TABLE T1 ( id NUMBER,
START_date DATE,
end_date DATE,
end_date1 DATE,
end_date2 DATE,
end_date3 DATE,
LEVEL1 number
)
/

[Code]...

I have data in the first table as mentioned above I need to insert multiple rows into the second table for the same ID depends on the level, If it is level 1 then two rows for same ID first reocrd start_date as the start_date and end_date as end_date from the table t1 for second record start_date is end_date in t1 and end_date for this record is end_date1 column in table t1.

If the level is 3 then the table t2 should have four records for one id and the phase is the value for each record for one ID for example in level 3 we have 4 records for one id and phase should be 1,2,3,4.

View 3 Replies View Related

SQL & PL/SQL :: How To Convert Multiple Column Values Into Single Column

Jul 19, 2013

CREATE TABLE TYPE
(
c1_type VARCHAR2 (10),
c2_type VARCHAR2 (10),
c3_type VARCHAR2 (10),
c4_type VARCHAR2 (10),
c5_type VARCHAR2 (10),
c6_type VARCHAR2 (10),
[code]......

actual output of the below query, but i want to display in different way

select * from type;

C1_TYPE C2_TYPE C3_TYPE C4_TYPE C5_TYPE C6_TYPE C7_TYPE C8_TYPE C9_TYPE
Region_D Region_E Region_F Region_D Region_E Region_D Region_M Region_D Region_E

The expected output should be like this below, how to write a query or which built in function used to get the below result,

Region_D
Region_D
Region_D
Region_D
Region_E
Region_E
Region_E
Region_F
Region_M

View 4 Replies View Related

SQL & PL/SQL :: Query To Convert Data In Single Column?

Oct 11, 2012

I have a below requirement let me know the optimized query.

Create table test_123 ( sr varchar2(1000));

Insert into test_123 values ('1,2,3,4,5');
Insert into test_123 values ('6,7,9,10,11');
Insert into test_123 values ('9,2,3,8,5');

I need output as :

Sr_output

1
2
3
4
5
6
7
8
9
10
11

I need all the values in the column sr in a single column and mutiple rows.

View 2 Replies View Related

SQL & PL/SQL :: How To Convert Rows Into Column

Sep 25, 2012

How to convert station & date wise multiple rows to date wise column. I have a table TEST like this,

STN_Name Date State
DELHI1-Sep-201G
DELHI2-Sep-201B
DELHI3-Sep-201G
DELHI4-Sep-201G
DELHI5-Sep-201G
DELHI6-Sep-201M
DELHI7-Sep-201G
DELHI8-Sep-201G
DELHI9-Sep-201G
DELHI ......... ..
DELHI 30 Sep 2012 G
KOLKATA1-Sep-201G
KOLKATA2-Sep-201B
KOLKATA3-Sep-201B
KOLKATA4-Sep-201B
KOLKATA5-Sep-201G
KOLKATA6-Sep-201M
KOLKATA7-Sep-201G
KOLKATA8-Sep-201G
KOLKATA9-Sep-201B

I want output like this

STN_Name1-Sep-20122-Sep-20123-Sep-20124-Sep-20125-Sep-2012............Sep 2012
DELHI G B G G G M
KOLKATA G B B B G M

View 2 Replies View Related

SQL & PL/SQL :: Convert Rows Into Column

Mar 22, 2012

can we show the following rows into column upto 1000 using sql query?

A
1
2
3
4
[code]...

Result should like this 1,2,3,4,5,6,7,8,...... 1000 including comma(,)

View 3 Replies View Related

SQL & PL/SQL :: Convert Particular Column To Rows?

May 10, 2012

SELECT a.objname, c.property1, c.value1
FROM datatable a, datatabledet c
WHERE a.OBID=c.DATAOBID
and a.CLASSNAME='Class1';
OBJNAME PROPERTY1 VALUE1
280-419-1994psCls1Attr3Attr1Value3
280-419-1994psCls1Attr4Attr1Value4
280-419-1994psCls1Attr5Attr1Value5

[code]....

After query output we put through front end code to make it in the following way i.e. convert rows into columns but with respective data value:

psCls1Attr3 psCls1Attr4 psCls1Attr5 psCls1Attr1 psCls1Attr2 psCls1Attr7
280-419-1994 Attr1Value3 Attr1Value4 Attr1Value5 Attr1Value1 Attr1Value2
280-419-1995 Attr1Value11Attr1Value21Attr1Value71

how to output in the above format using SQL.

View 4 Replies View Related

SQL & PL/SQL :: How To Convert Rows Data Into Column

Nov 20, 2011

how to convert rows data into column...

View 7 Replies View Related

SQL & PL/SQL :: Convert Rows As Column-Decode

Jul 3, 2012

I am having a table with following data:

DateProduct_nameQuantity_sold
12/6/2012Product11
12/7/2012product23
12/6/2012product34
12/7/2012Product12
12/7/2012product21
12/6/2012product35
12/7/2012product33
12/6/2012product24

Now I want this data in following manner:

For each date - how much is the Total quantity sold , sum of Product1 sold,Sum of product2 sold,etc. I am having more than 50 products in my table.

dateQuantity_soldProduct1Product2Product3
12/6/2012141 49
12/7/201292 43

I was trying this by decode but the sum of the product was not correct.

View 2 Replies View Related

SQL & PL/SQL :: Query To Convert Rows Into Column

Dec 11, 2009

I need a single select query which converts all the rows into a single value . Below is my requirement :

Create table email_tbl(emailid varchar2(30));
insert into email_tbl('1@y.com');
insert into email_tbl('2@y.com');
insert into email_tbl('3@y.com');
insert into email_tbl('4@y.com');

Now , I need a single select query which gives me the below results.

1@y.com,2@y.com,3@y.com,4@y.com

I have done the above by using a cursors in the pl/sql objects.But want to achieve this with a single sql/query.

View 7 Replies View Related

SQL & PL/SQL :: Convert Column To Rows Tabular Format

Jun 8, 2011

I have job, working hours, employee id, employee name in test_emp table. The job name and employees are not fixed in this table and it varies from project to project. We don't know how many employees are there and needs to be fetching on runtime.

I have the data like below

JOB---------WRKHR---EMPID-----EMPNM
ANALYST-----10------5478------RAMESH
MANAGER-----10------4258------SACHIN
LEAD---------10------4789------VIVEK
DEVELOPER---20------5632------ROHIT
ANALYST-----20------5843------VIRAT
MANAGER-----20------4789------VIVEK
PROGRAMMER-30------5479------SURESH
LEAD---------30------4258------SACHIN
DEVELOPER---30------5231------PRAVEEN

I need the output like below format.

JOB---------RAMESH--SACHIN--VIVEK--ROHIT--VIRAT--SURESH--PRAVEEN--TOTAL
MANAGER-----0--------10-------20-----0-------0------0---------0---------30
LEAD---------0--------30-------10-----0-------0------0---------0---------40
ANALYST-----10-------0---------0-----0------20------0---------0---------30
DEVELOPER---0--------0---------0-----20------0------0---------30--------50
PROGRAMMER-0--------0---------0------0------0------30--------0---------30
--TOTAL-----10-------40--------30-----20-----20-----30--------30--------180

View 6 Replies View Related

Fetching Multiple Rows For Single Column

Jun 25, 2012

I am trying to write a script where a particular post code from a table is having more than 3 telephone numbers.Both the columns are in the same table. How to fetch.

Table is P_Order
Columns are DELIVERY_POSTCODE and TEL_NO...
Condition DELIVERY_POSTCODE has more than 3 TEL_NO

View 1 Replies View Related

SQL & PL/SQL :: Query On Single Column To Display As Rows

Aug 5, 2010

I has a table of structure of varchar2 datatype.

NO
----------
1-2
3-4
5-6

desired output is:

SQL>1
2
3
4
5
6

The table has single column & the values may differ,that is, they may have 1-2-3-...-n in a single row, but the desired output is to be in the rows as shown above.

I tried concepts of SQL up to my knowledge, but I failed. The query to be done only in SQL.complete this query.

View 10 Replies View Related

SQL & PL/SQL :: Append More Rows In Single Clob Column

Apr 9, 2013

I have a query which returns nearly 20k rows, as per the requiremnet we need to append all these rows in specific format and insert into single clob column.in the below procedure test_clob.textt is clob field.

CREATE OR REPLACE PROCEDURE pro_test
v_mas_seq NUMBER (9);
v_gov_total NUMBER (20, 2);
v_emp_total NUMBER (20, 2);
v_text_exp CLOB;
v_pageaccess VARCHAR2 (15);
v_dto NUMBER (7) := 4011486;
v_batchno NUMBER (20) :=
[code]....

View 15 Replies View Related

SQL & PL/SQL :: Convert Columns To Rows With Extra Hard Coded Column

Mar 30, 2012

I've a query that sum up data from one table. But I've to convert them into rows.

Summary query result.

COL1 COL2 COL3 COL4
1000 2000 3000 4000

Test Table creation script.

CREATE TABLE TEST_TBL
(
COL1 NUMBER(14,2),
COL2 NUMBER(14,2),
COL3 NUMBER(14,2),
COL4 NUMBER(14,2)
) ;

INSERT INTO TEST_TBL VALUES( 1000, 2000, 3000, 4000 ) ;

Expected result

A1 1000
A2 2000
A3 3000
A4 4000

A1, A2, A3, A4 are hard coded fixed values.

I could have done this but not a good idea in case table TEST_TBL is not a single row table but an inline query on 1,00,00,000 records with summary functions. In my table I've a summary query instead of single row table.

SELECT 'A1', COL1 FROM TEST_TBL
UNION ALL
SELECT 'A2', COL2 FROM TEST_TBL
UNION ALL
SELECT 'A3', COL3 FROM TEST_TBL
UNION ALL
SELECT 'A4', COL4 FROM TEST_TBL

View 12 Replies View Related

PL/SQL :: Concatenating Columns (in Multiple Rows) To One Column In Single Row

Nov 28, 2012

column1    column2            column3    column4

12                Mar-21-2005 BDW        blah blah blah
11               Feb-07-2001    ZV            ha ha ha
12                Jan-02-2002   YM           zuck zuck zuckI want a view that has that data like this:

column1    column2         

12                Mar-21-2005 - BDW - blah blah blah; Jan-02-2002 - YM     -      zuck zuck zuck
11               Feb-07-2001    ZV            ha ha haCan you help with SQL ?

I tried to use this Oracle LISTAGG function in the SQL, but got a "string concatenation limit exceeded"

View 3 Replies View Related

PL/SQL :: Multiple Row Convert Into Single Row

Jan 4, 2013

How do I convert multiple rows into single row data. For example.....

I am looking for oracle query for below table output that would have a sql query output as query output below.

I was trying with connect by but was unable to prepare query.

Table output_
   ---------------------------
    ID      TYPE        VALUE
    ---------------------------
    1012    1           2
    1012    6           77
    1015    1           1
    1015    6           78
    1018    1           2
    1018    6           79

Query output_

    ----------------------------   
    ID      VALUE1      VALUE2
    ----------------------------
    1012    2           77
    1015    1           78
    1018    2           79

View 5 Replies View Related

SQL & PL/SQL :: Convert Procedure To Single Query

Jul 26, 2012

I want to replace below multiple call to procedure with a Single query. Currently this proc is getting called multiple times from application.

FUNCTION f_get_shows_info(i_booking_wk_id IN NUMBER, i_screen_id IN NUMBER)
RETURN VARCHAR2 IS
v_act_shows booking_wk_screen.act_shows%TYPE;
v_expected_shows booking_wk_screen.expected_shows%TYPE;
v_return VARCHAR2(50);
BEGIN
SELECT NVL(act_shows, 1), NVL(expected_shows, 1)
INTO v_act_shows, v_expected_shows
FROM booking_wk_screen
WHERE booking_wk_id = i_booking_wk_id
[code]...

Is there anyway through which we can achieve this in Oracle 10g.

View 16 Replies View Related

SQL & PL/SQL :: How To Convert A Single Ragged Table

Dec 11, 2011

how to convert a single 'ragged' table like:

MAIN_KEY SUB_KEY DATA
ABC 1 A
ABC 2 B
ABC 3 C
DEF 1 X

where:

MAIN_KEY and DATA are indeterminate, and
SUB_KEY = 1 .. n [always starts with 1 for a given MAIN_KEYD]

into:

MAIN_KEY SUB_KEY DATA
ABC 1 A
ABC 2 B
ABC 3 C
ABC 4 {null}
ABC 5 {null}
DEF 1 X
DEF 2 {null}
DEF 3 {null}
DEF 4 {null}
DEF 5 {null}

in the case where n = 5?

View 6 Replies View Related

RAC/ASM Clusterware Installation :: Verification Of Steps To Convert Single Node To RAC

Jan 16, 2013

I have a single node Oracle E-Biz 12.1.3 Installation.We plan to convert this to a dual node RAC install and I wanted to run by the steps to perform this AND clone over the current production system to the new RAC system (note this will not be using ASM - but will be based on NetApp NFS)

1. Install GRID 11.2.0.3
- installed acorss two nodes, Binaries can be shared
- voting disks / cluster rigistry MUST be shared

2. Install Database Software for RAC
- Binaries cannot be shared and must be installed on each node independently

3. Configure the GRID for database (database / listeners)

4. Clone over the stand alone system (clone database as RAC)

I will be using SCAN - and therefore would expect all the web services / concurrent manager nodes to point to the SCAN hostname as opposed to individual host names.

View 1 Replies View Related

SQL & PL/SQL :: Convert Many Rows To One

Sep 17, 2012

I use Oracle 11g and a Middleware which sends the SQL Statements to the database. That's why I can't send you loggings.

However, I' got this SQL:

With CTE
AS
(
select * from
data A2
WHERE
A2.ID ='536031'
AND
A2.AttrID = '6'
)

That code gives me the following result:

ID.........Version....AttrID.......group
536031......3.........6..............test5
536031......3.........6..............test6

What I try to do. I want to get all groups. The Groups should be in one column...the the result must be the following:

ID.........group
536031...test5, test6

In SQL server I always used

SELECT ID,
STUFF((SELECT ',' + [group] FROM CTE WHERE ID = c.ID ORDER BY [Version] FOR XML PATH('')),1,1,'')
FROM (SELECT DISTINCT ID FROM CTE)c

to achieve that. Is there a similar function in oracle like XML PATH? Or another way the get the result?

View 12 Replies View Related

JDeveloper, Java & XML :: Convert Complete Oracle Database In Single XML File

Dec 14, 2010

Inspiration of a java program that converts a oracle database to one single XML document?

View 1 Replies View Related

How To Convert Rows To Columns

Jun 18, 2011

how to convert rows to columns ?

View 1 Replies View Related

Convert Rows Into Columns

May 30, 2007

Below is the schema of a table:

TableName : PropertyValue

Columns: PropertyID Number
Value varchar
ValueID Number
Phone Number

Requirement: Create a view based on the table"PropertValue'. There could be 4 different PropertyIDs for each phone.

e.g.
PropertyID Value ValueID Phone
1 'xyz' null 1234
2 null 11 1234
3 null 12 1234
4 null 13 1234
1 'pqr' null 5678
2 null 14 5678
3 null 15 5678
4 null 16 5678

Required View:

Phone Attrib1 Attrib2 Attrib3 Attrib4
1234 'xyz' 11 12 13
5678 'pqr' 14 15 16

I tried creating the required view using 'CASE' statement and group by but its returning multiple rows.

select case when PropertyID=1 then VALUE end as Attrib1,
case when PropertyID=2 then ValueID end as Attrib2,
case when PropertyID=3 then ValueID end as Attrib3
case when PropertyID=4 then ValueID end as Attrib4
from (
select Phone, PropertyID, ValueID,Value
from PropertyValue
group by Phone, PropertyID, ValueID,Value
)

View 1 Replies View Related

Convert Columns Into Rows?

Aug 3, 2009

i have a table with this data :

id name
1 a
2 b
3 c
4 d

and i want the o/p like this,

col1 col2 col3 col4 col5
id 1 2 3 4
name a b c d

means i want to convert my columns into rows.

View 1 Replies View Related

SQL & PL/SQL :: Convert Rows As Columns

Jun 7, 2010

Need to convert columns into rows like expected

service_key consumer_key the_key fin_score_type granu rno

20100201 1 p_1 100MONTH1
20100201 1 p_0 100MONTH1
20100201 1 d_6 100MONTH1
20100201 1 t_2 200MONTH1
20100201 1 d_5 100MONTH1

But it should display like below,All the the_key types as differnet colmns instead of rows,Since need to insert those values in different tables.

expected o/p consumer_key p_code p_val d_code d_val t_code t_values granula

service_key
20100201 1 p_0 100 d_6 100 t_2 200 MONTH1
20100201 1 p_1 d_5 100 MONTH1

View 5 Replies View Related

SQL & PL/SQL :: Convert Rows To Columns?

Aug 2, 2010

consider the following tables

WITH table1 AS -- this table contain a list of column names
(
SELECT 11 cid, 'TEK' group_nm, 'TYPE DESC' column_nm FROM dual
UNION ALL

[Code].....

i have 3 tables, one that contains name of columns(table1), another one contain number of rows (table2) and the last table contain

the values for columns in table1 for each row in table2.

what i want to do is join all 3 tables and display the output as follow

TYPE DESC NAME P DATE TYPE_PCT
====================================================
Good John 8/21/2010 0.009
BAD Ken 4/11/2010 10.009
Medium Rob 8/1/2010 0.001

as you can see the columns names comes from table1, and the values comes from table3. i want to join these tables so that it display the output above

View 2 Replies View Related

Real Application Clusters :: Convert 10g Single Instance (uses ASM) Database To RAC - Reconfigure Fails?

Oct 5, 2012

I have 11gR2 GI installed on two nodes. I am trying to convert a 10g single instance (uses ASM) database to RAC and getting this error. I am trying using 12c as well as manually by using rconfig.

[main] [21:19:15:145] [ASMInstance.initialize:135] First record =[Ljava.lang.String;@958bb8
java.lang.NullPointerException
at oracle.sysman.assistants.rconfig.engine.ASMInstance.initialize(ASMInstance.java:153)
at oracle.sysman.assistants.rconfig.engine.Step.execute(Step.java:283)

[code]...

View 1 Replies View Related

Convert Rows To Columns In A Table?

Apr 24, 2012

How do I convert rows in oracle table to columns by writing a query?

Here is my table.

EID QNo Qual YOP
101 1 B.Tech 2004
101 2 M.Tech 2006
102 1 B.Tech 2003
102 2 M.Tech 2005
102 3 MBA 2007

Now I want the above table in the following format......

EID Qual1 YOP1 Qual2 Yop2 Qual3 Yop3
101 B. Tech 2004 M.Tech 2006
102 B. Tech 2003 M.Tech 2005 MBA 2007

I have maximum of 8 Qualifications, how to achieve this in oracle.

View 3 Replies View Related

Convert Rows To Multiple Columns

Aug 30, 2004

I have a table called N1

N1_no Srvarea_type_cd
1 P
1 P
2 C
2 C
2 C
3 I

Another table N2

N1_no srvarea_txt
1 ABCD
2 DEFG
3 XYZA

Can i get a query so that the data can be displayed in the following way ..

P C I
ABCD DEFG XYZA

View 3 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved