Linked Questions
91 questions linked to/from SQL Query to concatenate column values from multiple rows in Oracle
125 votes
11 answers
519k views
How can I combine multiple rows into a comma-delimited list in Oracle? [duplicate]
I have a simple query: select * from countries with the following results: country_name ------------ Albania Andorra Antigua ..... I would like to return the results in one row, so like this: ...
82 votes
4 answers
382k views
How can multiple rows be concatenated into one in Oracle without creating a stored procedure? [duplicate]
How can I achieve the following in oracle without creating a stored procedure? Data Set: question_id element_id 1 7 1 8 2 9 3 10 3 ...
63 votes
1 answer
122k views
Is there any function in oracle similar to group_concat in mysql? [duplicate]
My inputs are in this way. col1 col2 1 a 1 b 2 c 2 d 2 e O/p: Should Be like col1 col2 1 a,b 2 c,d,e I want a query that can be fired at DB level. I've ...
32 votes
7 answers
95k views
Is there an Oracle SQL query that aggregates multiple rows into one row? [duplicate]
I have a table that looks like this: A 1 A 2 B 1 B 2 And I want to produce a result set that looks like this: A 1 2 B 1 2 Is there a SQL statement that will do this? I am using Oracle. Related ...
4 votes
2 answers
33k views
Oracle - SQL to concatenate multiple rows [duplicate]
Let’ say I have a table with 3 columns ID INTEGER, OFFSET INTEGER, STR VARCHAR(50) Containing values: ID OFFSET STR 1 1 TestSTR1 1 2 ...
9 votes
2 answers
12k views
Equivalent of PostgreSQL's array_agg in Oracle XE 11.2 [duplicate]
I have a Oracle 11g XE database and I have a query the result set: ID Category 1 Cat1 1 Cat2 2 Cat3 2 Cat4 I want to get distinct id's with all related categories in same row as comma ...
0 votes
1 answer
15k views
Oracle SQL - Multiple rows into one field [duplicate]
I have a table like this: I need a query (no PL/SQL) that shows this output: So for each Product ID I want the distinct values of Delivery Type in the field Delivery Type. Is there a way to get this ...
2 votes
1 answer
5k views
Oracle SQL - How to show one to many relationship in a single row? [duplicate]
I have a table called MY_MOVIES with two columns: MOVIES and GENRES like this (the relationship is one movie to many genres): GENRE MOVIE ---------- -------------- ACTION ...
3 votes
1 answer
2k views
Fast way to generate concatenated strings in Oracle [duplicate]
Don't we hate when evil coding comes back to haunt? Some time ago I needed to generate a string concatenating some fields for some more processing later. I thought it would be a good idea to do if ...
-1 votes
1 answer
5k views
How to get group_concat() like output from oracle so that I can get a comma separated list from a sigle column for each group by row [duplicate]
I am stuck in situation where I need a comma separated list from group by result sets. Let me give you a typical schema : username | lotno | img ------------------------ ...
-2 votes
1 answer
3k views
How to group and concatenate results from multiple records? [duplicate]
I have a query like: select a.id, b.value from a left join b on a.name = b.name where a.id = 12345; And I get results like id value -------- 12345 value1 12345 value2 However I would like to get a ...
1 vote
1 answer
4k views
Oracle Sql query to return the column result in single row [duplicate]
I have below select query: select distinct(e.ENGINE_ID), e.ENGINE_NAME, os.OBJECT_STATUS, br.NAME, env.NAME from ENGINE e, RATOR_MONITORING.OBJECT_STATUS os, ...
1 vote
1 answer
4k views
How can I return multiple row values into one cursor variable in Oracle SQL? [duplicate]
I have a package in oracle that contains one stored procedure. It takes a date as a input and a number as input, and outputs the data into a ref_cursor. The purpose of the stored procedure is to ...
0 votes
2 answers
2k views
Get Comma Separated Ids in variable plsql [duplicate]
I have a table like this id | Name =========== 1 | A 2 | A 3 | A 4 | B 5 | B 6 | C i am writing select id from tbl where name = "A", i want to get all three ids (1,2,3) like this ...
0 votes
2 answers
2k views
SQL SELECT group multiple rows together when LISTAGG and WM_CONCAT are not available [duplicate]
I'm having trouble explaining this, so if someone can make adjustments to the title or question then please do. I have a simple SQL query that I'm running SELECT orders.customer_no, orders.order_no ...