Result right now I am getting is:

EmployeeNo  Column1   Column2
1           |  NULL       | Column2
1           |  Column1    |   NULL 

I want like

EmployeeNo  Column1   Column2
1          | Column1  |   Column2

Kindly provide any help or way to do this

Thanks in advance

closed as off-topic by ypercubeᵀᴹ, Mark Storey-Smith, Paul White, Philᵀᴹ, Mikael Eriksson Jun 9 '14 at 11:49

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Too localized - this could be because your code has a typo, basic error, or is not relevant to most of our audience. Consider revising your question so that it appeals to a broader audience. As it stands, the question is unlikely to help other users (regarding typo questions, see this meta question for background)." – ypercubeᵀᴹ, Mark Storey-Smith, Paul White, Philᵀᴹ, Mikael Eriksson
If this question can be reworded to fit the rules in the help center, please edit the question.


The simplest way to merge rows is with an aggregate function such as MIN/MAX. These functions will ignore nulls (see MSDN) and can operate similarly to ISNULL/COALESCE with aggregation. For example:

  MAX(Column1) AS Column1,
  MAX(Column2) AS Column2
FROM MyTable
GROUP BY EmployeeNo

This will return the sample desired results. If your only goal is to merge columns with null values into rows with data in those columns, it doesn't matter whether you use MIN or MAX - the result set will be the same.

Not the answer you're looking for? Browse other questions tagged or ask your own question.