All Rows in to a Single Column?
Hi,
I am Using Oracle 11g Database Release 1,I am try to get the Primary Column for a Table in My Database Normally We get the Output as
Header
Column1
Column2
Column3
But I need the Output as
Header
Column1,Column2,Column3
Please Advice
Thank U
SHAN
Hi,
you could use Pivot function in Oracle since you are in 11g, please see the link.
http://www.oracle.com/technology/pub/articles/oracle-database-11g-top-features/11g-pivot.html
If in 10G.
http://www.orafaq.com/node/55
thanks
Similar Messages
-
All row data in a single column
i have a table with the following data
id name age salary dept city state country
1 abcd 22 20000 IT X Y XYZ
2 efgh 23 30000 IT X Y XYZ
i need the output as
1,abcd,22,20000,IT,X,Y
2,efgh,23,30000,IT,X,Y
in a single column separated by a comma(,)
is it possible to get?
please any one help me out with the sql/PL SQL queryselect col1 || ',' || col2 || ',' || ...
-
Merging 2 rows data into a single column in OBIEE
Hi All,
Requirement is "Merging 2 rows into a single column"
Scenario: data from table called "transactions_table"
Id
transaction no
transaction name -------------------------------quantity
100
1
abc
1000
100
2
def
2000
Required out put:
Id
Transactions & Quantity
100
abc(1000),def(2000)
Please provide me solution, and let me know if any additional information is required.
Thanks in advance to all of you.can you please share your data like below
column1, column2 .....
and where are you trying to do this? at answer or bi admin tool?
there are a few ways to do this. -
Merging 2 rows data into a single column in OBIEE 11g
Hi All,
Requirement is "Merging 2 rows into a single column"
Scenario: data from table called *"transactions_table"*
Id ------------- transaction no ----------------------- transaction name -------------------------------quantity
100 ----------- 1 ----------------------- abc ------------------------------ 1000
100 ----------- 2 ------------------------ def ------------------------------ 2000
Required out put:
Id ----------------- Transactions & Quantity
100 -------------- abc(1000),def(2000)
Please provide me solution, and let me know if any additional information is required.
Thanks in advance to all of you.
Regards,
chrscheck the below link, that may help you.
Re: Horizontal value display
If it is helpful, please mark as correct or helpful -
Finding the minimum value across multiple rows (not in a single column)
Hello,
I am running some ad-hoc SQL to test a website implementation of a spec. The ad-hoc sql gives me a set of date values for a specific widget (called a Task). I need to find the Minimum of either (Task.EndDate + 1 year) or the MAX date from the list
of other dates. I can easily get all of these dates, and compare them visually, but I'm not sure how to make SQL give me just the single value that I want. In the image below, you can see the results. The blue cell is the value I should get if I were to retrieve
a single value.
select
[EndDate+12Mo] = DATEADD(year,1,t.EndDate)
, [TaskEdit] = t.EditTS
, [ResearchEdit] = (select x.editts from Research x where t.researchid = x.researchid)
, [DeliverableEdit] = (select max(x.EditTS) from Deliverable x where t.taskid = x.taskid)
, [RTPEdit] = (select max(x.EditTS) from ResTaskParticipant x where (t.taskid = x.taskid and t.researchid = x.researchid) or (t.researchid = x.researchid and x.TaskID is null) )
, [RelatedTaskEdit] = (select max(x.EditTS) from Task_Related x where t.taskid = x.Task1ID or t.TaskID = x.Task2ID)
, [CrosscutEdit] = (select max(x.EditTS) from Task_Crosscut x where t.taskid = x.taskid)
, [TaskFundingEdit]= (select max(x.EditTS) from TaskFunding x where t.taskID = x.taskID)
, [ContractFundingEdit]= (select max(x.EditTS) from TaskFunding x inner join ContractFunding y on x.ContractFundingID = y.ContractFundingID where t.taskID = x.taskID)
from task t
where
t.tasknumber =
'2123.001'
Thanks!
JenniferSounds like this to me
select CASE WHEN [EndDate+12Mo] < MAX(dt) THEN [EndDate+12Mo] ELSE MAX(dt) END AS YourDateValue
from
SELECT [EndDate+12Mo],dt
from
select
[EndDate+12Mo] = DATEADD(year,1,t.EndDate)
, [TaskEdit] = t.EditTS
, [ResearchEdit] = (select x.editts from Research x where t.researchid = x.researchid)
, [DeliverableEdit] = (select max(x.EditTS) from Deliverable x where t.taskid = x.taskid)
, [RTPEdit] = (select max(x.EditTS) from ResTaskParticipant x where (t.taskid = x.taskid and t.researchid = x.researchid) or (t.researchid = x.researchid and x.TaskID is null) )
, [RelatedTaskEdit] = (select max(x.EditTS) from Task_Related x where t.taskid = x.Task1ID or t.TaskID = x.Task2ID)
, [CrosscutEdit] = (select max(x.EditTS) from Task_Crosscut x where t.taskid = x.taskid)
, [TaskFundingEdit]= (select max(x.EditTS) from TaskFunding x where t.taskID = x.taskID)
, [ContractFundingEdit]= (select max(x.EditTS) from TaskFunding x inner JOINContractFunding y on x.ContractFundingID = y.ContractFundingID where t.taskID = x.taskID)
from task t
where
t.tasknumber =
'2123.001'
)t1
UNPIVOT(dt FOR cat IN ([TaskEdit]
, [ResearchEdit]
, [DeliverableEdit]
, [RTPEdit]
, [RelatedTaskEdit]
, [CrosscutEdit]
, [TaskFundingEdit]
, [ContractFundingEdit]))u
)r
GROUP BY [EndDate+12Mo]
Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs -
Concatenate multiple row values into single column value
Hello,
Can anyone please refresh my memory on how to concatenate multiple row values into a single column value.
In the following query, I will get multiple denial reasons per application and I would rather return all denial reasons on one line.
SELECT a.application_id, a.membership_number,
r.reason_text AS denial_reason,
a.appl_receipt_date AS application_receipt_date,
a.plan_request_1 AS application_plan_code,
a.adjudication_date AS application_denial_date
FROM application a, PLAN p, application_reason ar, reason r
WHERE a.plan_request_1 = p.plan_cd
AND a.application_id = ar.application_id
AND ar.reason_id = r.reason_id
AND a.adjudication_cd = 'D'
AND a.appl_receipt_date BETWEEN '01-jan-2006' AND '31-dec-2006'
AND p.plan_type_id = 12 and a.application_id = :appId
ORDER BY application_id
Any help is greatly appreciated.
Thanks,
-Christinefound the following
SELECT deptno,
LTRIM(MAX(SYS_CONNECT_BY_PATH(ename,','))
KEEP (DENSE_RANK LAST ORDER BY curr),',') AS employees
FROM (SELECT deptno,
ename,
ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) AS curr,
ROW_NUMBER() OVER (PARTITION BY deptno ORDER BY ename) -1 AS prev
FROM emp)
GROUP BY deptno
CONNECT BY prev = PRIOR curr AND deptno = PRIOR deptno
START WITH curr = 1;
DEPTNO EMPLOYEES
10 CLARK,KING,MILLER
20 ADAMS,FORD,JONES,SCOTT,SMITH
30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
3 rows selected.at http://www.oracle-base.com/articles/10g/StringAggregationTechniques.php -
Hi All
Need some assistance, 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*
thanks for your help in advance.
i did look on the web but can't find a solution that is easily understood.Hi,
855161 wrote:
thanks for responding quickly.
the link example seems not to work for me:
below is the information you have requested:Below is some of what I requested. The CREATE TABLE and INSERT statements seem to be missing.
1. duplicate values have no effect
2. list doesn't need any order
3. Version 10.2.0.5.0 For that, I recommend the user-defined aggregate function called STRING_AGG in the Oracle Base page, but called STRAGG by most of the people who use it. You have to copy and run about 60 lines of code from the Oracle Base page, or from AskTom one time, but once you have it installed, the job is as simple as
SELECT MIN (rnum) AS rnum -- ROWNUM isn't a good column name, since it's the same as a pseudo-column
, STRAGG (count_1) AS count_1_list
FROM table_x
;Hundreds of other jobs you have in the future will be just as easy, and you won't have to go through the installation process again.
Relevant information:
1. table columns : count_1
all rows should become a single row with ',' in between
example:
select * from t1;
output:
Rownum count_1
1 8217
2 6037
3 5368
4 5543
5 5232
Desired results :
Rownum count_1
1 8217, 6037, 5368, 5543, 5232
Edited by: 855161 on Dec 11, 2012 1:25 PMThe main problem with STRAGG is that it doesn't create a list in order. You said that's not an issue in this case, but if you ever do need output in order, then the best option in Oracle 10 is the SYS_CONNECT_BY_PATH technique. The main Oracle-Base page shows how to use SYS_CONNECT_BY_PATH in Oracle 9. Of course, that works in all later versions too, but in version 10 a simpler way, using CONNECT_BY_ISLEAF, became available. See the Oracle-Base Comments Page for the eaiser Oracle 10 technique. -
Hi all.
What is the sql statement for insert a single column to the table?
Let say i gt a student table and a admino column.
Thanku can never insert a single column.
atleast u should insert blanks to the other fields.
inserting a row is possible , inserting single column will not be a normalised table.
by the way u can update a single column. -
Multiple Selection Property in Single Column Listbox
Hello All,
I have taken a Single-column list box and have enable the multiple selection property of the listbox.
In fact, i want to find out the values of the multiple rows selected in the listbox. But, i couldn't found any of the property of this listbox that can indicate the index or value of the multiple lines that are selected.
Can anybody help me to resolve this issue? What is the approach i can take to find out the multiple rows selected in the listbox?
Regards,
NishantNishant wrote:
Hello All,
I have taken a Single-column list box and have enable the multiple selection property of the listbox.
In fact, i want to find out the values of the multiple rows selected in the listbox. But, i couldn't found any of the property of this listbox that can indicate the index or value of the multiple lines that are selected.
Can anybody help me to resolve this issue? What is the approach i can take to find out the multiple rows selected in the listbox?
Regards,
Nishant
Here is an example where the value is read from a property node.
the Value becomes an array when you elect a selection mode that allows multiple selections. (and thats the reason you can't write Selection mode while the VI is running
Jeff
Attachments:
Listbox.vi 7 KB -
Display two heading in single column using ALV report
Hi Experts,
I got a requirement for displaying 2 rows heading in a single column report. Is it possible that I can perform this task using ALV. How to get this 2 rows in ALV.
This is a criteria that need to be output in ALV REPORT.
MATERIAL CODE--MATERIAL NUMBERSTORAGE LOC----SLOC1 SLOC2
--DATE--DATE1 DATE2
123445--TEST MATERIAL22--
3
As mentioned above storage loc and date will be changing with respect to data dynamically and under this double heading qty will be displayed.
Just want to know how to get double heading. It is clear that how to display dynamically but unaware of double heading using fieldcatalog.
Regards,
YahyaHi Yahya,
Please pass row position in fieldcatalogue for the respective columns.
E.g MOVE '2' to w_fieldcat-row_pos. " This will display the field in 2nd row.
Thanks,
Rupali -
Option to insert into all rows
How would I create an option that gives the user a choice of inserting a value into all rows or just a specific row in a table?
Doris,
I'm assuming you mean "update" rather than "insert", since "inserting a value into all rows" doesn't really make sense to me.
Anyway, there's lots of ways you can present this to the users, but at the backend it will come down to your use of a where clause, e.g.
"update employees set salary = 20000"
will update all rows and set the salary column to 20000, whereas -
"update employees set salary = 20000 where emp_id = 37"
will only update the row for the employee with emp_id = 37.
Hope this helps. -
How to join 2 rows under single column header
i want to join 2 or more rows under a single column header. as shown "container details" is the column name with "h", "w", and "s" and the sub column names. so my header should contain all these four names and my 3 rows under h,w and s should be clubed under this container details.
anyone help me out. thanks in advance.
container details
| h | w | sBummer, I just tried the link (which I saved from a couple months ago) and it doesn't work. This was a great site for showing how to do various things in Swing. Sorry for the bad link. Maybe someone saved the sites info or knows where it may have moved. Dang...
-
Unique row based on two columns and single column
Dear Members,
I have a table which contains duplicate rows, for which a query should be able to fetch the unique row from the table. Here the unique is not based on one column, but it should be on two columns and also check for uniqueness on one column.
create table addr ( firstname varchar2(10), lastname varchar2(10), area varchar2(3));
insert into addr values('bob', 'james', '1');
insert into addr values('bob', 'james', '1');
insert into addr values('harry', 'bert', '1');
insert into addr values('jimmy', 'bert', '1');
insert into addr values('sam', 'mac', '1');
insert into addr values('sam', 'knight', '1');
insert into addr values('tom', 'sand', '1');
insert into addr values('cat', 'mud', '1');
The output of query should contain 3 rows.
bob - james
harry - bert or jimmy - bert [ either one of them, but not both ]
sam - mac or sam - knight [ either one of them, but not both ]
tom - sand
cat - mud
SELECT firstname, lastname as total from addr WHERE area = '1' GROUP by firstname,lastname; This does not take of single column duplication..
Any suggestions..SQL> with t_data
as
select 'bob' as firstname, 'james' as lastname, '1' as area from dual union all
select 'bob', 'james', '1' from dual union all
select 'harry', 'bert', '1' from dual union all
select 'jimmy', 'bert', '1' from dual union all
select 'sam', 'mac', '1' from dual union all
select 'sam', 'knight', '1' from dual union all
select 'tom', 'sand', '1' from dual union all
select 'cat', 'mud', '1' from dual
SELECT
firstname,
lastname,
area
FROM
SELECT
t.*,
row_number() over(partition BY firstname order by 1) rn,
row_number() over(partition BY lastname order by 1) rn1
FROM
t_data t
WHERE
rn = 1
AND rn1 =1 ;
FIRSTNAME LASTNAME AREA
bob james 1
cat mud 1
jimmy bert 1
sam knight 1
tom sand 1
SQL> -
Convert single column into rows
hi Gurus,
I have one table test colums are id and name.
id number
name varchar2
data is like
id name
1 xy
2 xyy
3 mm
4 pp
Now my requirement is to convert single column id into rows
i,e my output should be of singel rows like :- 1,2,3,4
How to achive this result .
I dont have any idea to do this query.
Please help guys.
Thanks in advance.
VijayWell,
As long as your code doesn't have to run in production, simplest way is:
WM_CONCAT (but it's not documented)
or use XMLAGG, it's simpler than a connect by:
MHO%xe> with t as (
2 select 1 col, 'xy' str from dual union all
3 select 2, 'xyy' from dual union all
4 select 3, 'mm'from dual union all
5 select 4, 'pp' from dual union all
6 select 8, 'pp' from dual union all
7 select 12, 'pp' from dual union all
8 select 40, 'pp' from dual
9 )-- actual query, based on id's generated above:
10 select rtrim(xmlagg(xmlelement(e,col||',')).extract('//text()'),',') col
11 from t;
COL
1,2,3,4,8,12,40
1 rij is geselecteerd. -
HOWTO read the table columns (ALL ROWs of Colm)and display in a texteditor
I am trying to fetch details from VC Table to read all rows of a column. But I am able to get only one row of the column.
Can we export or import data of multiple rows of a column to a texteditor ???Hi Sandeep
Thanks for your reply, As I understand , I have sent the element property to multiselect.
But this is only useful when user select manually at runtime on the columns .. but I am at design time I need to pull column's all the rows using Formula, where I can get only single select at present.
How can I do the multiselect using formula.?
thanks in advance
Maybe you are looking for
-
Why cant I create a playlist for my music/song videos? Continuous play is also not possible in the video app on the phone!!!! previously, prior to IOS 6, it was possible to have both music videos & songs mixed in the same playlist in the music app
-
Create a client using SD_CUSTOMER_MAINTAIN_ALL and account group
Hi all, I´m using the bapi SD_CUSTOMER_MAINTAIN_ALL to create a new client with good result, now in transaction XD01 the functional consulter are using the field account group RF02D-KTOKD, they are using this field to activate the Hierarchie in SAP.
-
Sleeping Clients - WLC 7.6
We are running 7.6 on our 5508-WLC. We have a number of issues w/ 'i-clients' when they go asleep. From what I can tell, I need to enable the 'sleeping clients' feature (not just the session and idle timeouts). On our WLANs we use Layer-2 (WPA+WPA2
-
Hi All, Need some advice on the below I wanted to capture a reference image in which i have created a capture .iso file from Task sequence media and ran the iso on the reference machine 1. Seems it has taken the image but the sysprep has destroyed th
-
Add a custom email alias to all my mail enabled users
Hey Everyone, I'm trying to add an email alias to all my mail enabled users using powershell. I'm in a dir sync setup can I do something like the below.Of course the smtp:$($a.lname)_$($[email protected] isn't working for me. It was posted online as