I'm trying to combine rows in SQL Server.
Assume I have a table like:
C1 | C2 | C3
1 | A |
1 | |
1 | | B
2 | A |
2 | | C
And I want to end up with:
C1 | C2 | C3
1 | A | B
2 | A | C
Any way I can do this with one query?
At the moment I'm parsing the data manually with c#, but it's slow, and I can't limit the number of rows that are returned easily.
Thanks in advance!
For your example data
SELECT C1,
MAX(C2) AS C2,
MAX(C3) AS C3
FROM YourTable
GROUP BY C1
SQL Fiddle
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