There is the following table called P_FAMILIA
:
|ID | NAME | SOLDADOS |
|---|------------|------------|
| 1 | Stark | 30000 |
| 2 | Targaryen | |
| 3 | Lannister | 15000 |
| 4 | Greyjoy | |
When making the following query
SELECT F.NAME
FROM P_FAMILIA F
I get
| NAME |
|------------|
| Stark |
| Targaryen |
| Lannister |
| Greyjoy |
I want to display the result of the query as follows:
| NAME |
|---------------------------------|
|Stark,Targaryen,Lannister,Greyjoy|
Update
Try to upload the schema to http://sqlfiddle.com/ but the application has problems when the engine " Oracle 11g R2
" is chosen
Scheme:
-- Crear tabla
CREATE TABLE P_FAMILIA
(
ID INT,
NAME VARCHAR2(30 BYTE),
SOLDADOS FLOAT(126)
);
-- Llave primaria
ALTER TABLE P_FAMILIA
ADD PRIMARY KEY (ID);
-- Insert Statements
Insert into P_FAMILIA
(ID, NAME, SOLDADOS)
Values
(1, 'Stark', 30000);
Insert into P_FAMILIA
(ID, NAME)
Values
(2, 'Targaryen');
Insert into P_FAMILIA
(ID, NAME, SOLDADOS)
Values
(3, 'Lannister', 15000);
Insert into P_FAMILIA
(ID, NAME)
Values
(4, 'Greyjoy');
COMMIT;
I understand that from the example you have given that what you are looking for is this:
If not, I ask you to describe in detail how it is not similar to what you ask for.
By the way, Oracle's LiveSQL does work, in case you want to test and share.
The following should work:
Good day,
To be able to concatenate the values of the rows
You could use a function to return the grouped data or an anonymous block:
Or you can use the analytical functions "LEAD" or "LAG"
This should work (sample query):
It would show:
EDITION
You can try this:
Result