'SQL Oracle fusion lines with same id
Here is a simplification of my problem:
SELECT 123 id, 1 toto , NULL titi FROM dual
UNION
SELECT 123 id, null toto , 2 titi FROM dual
->
ID |TOTO|TITI|
---+----+----+
123| 1| |
123| | 2|
I would like to have a result like this (keeping those 2 selects):
ID |TOTO|TITI|
---+----+----+
123| 1| 2 |
Not sure how to fusion those 2 lines
One ugly solution is:
SELECT id, min (toto), min(titi)
FROM (
SELECT 123 id, 1 toto , NULL titi FROM dual
UNION
SELECT 123 id, null toto , 2 titi FROM dual
)
GROUP BY id
Solution 1:[1]
SELECT id, min (toto), min(titi)
FROM (
SELECT 123 id, 1 toto , NULL titi FROM dual
UNION
SELECT 123 id, null toto , 2 titi FROM dual
)
GROUP BY id
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Tyvain |
