views:

29

answers:

2

What would it be the simplest way to merge a result like this from a sql query to be displayed in an asp.net gridview?

NULL   Tarde Fer  W. Lunes
Mañana NULL  Fer  W. Lunes

I need the result to look like this

Mañana Tarde Fer  W. Lunes
+1  A: 

Do it upstream from the UI (on the server returning the results, in other words,) and group on an ID field returning the max() field values when you want to exclude nulls.

Beth
+1  A: 

Assuming Table

Col1      Col2     Col3    Col4
-------   ------   ------  --------
NULL      Tarde    Fer     W. Lunes
Mañana    NULL     Fer     W. Lunes

Then

SELECT MAX(Col1) AS Col1, MAX(Col2) AS Col2, Col3, Col4
FROM YourTable
GROUP BY Col3, Col4
Martin Smith