I have a query with these results:
A | 1
A | 2
B | 1
B | 2
B | 3
How do I get the results to be like this:
A | 1
| 2
B | 1
| 2
| 3
Here is one way:
SELECT CASE WHEN rn = 1 THEN c1 ELSE NULL END || ' | ' || c2
FROM (SELECT c1, c2, ROW_NUMBER() OVER (PARTITION BY c1 ORDER BY c2) rn
FROM your_table);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With