I used a sub select to get the data I want. I'm struggling to merge it all into one row now though.

This is an example of the result where its bike but there are loads on them:

bike    bike    null    null    bike    6       6    
bike    bike    null    null    bike    null    null     
bike    bike    2       2       bike    null    null

Any idea how I can merge or 'join', if you will, these rows together to act as one?

Output would ideally be bike 2 2 6 6.

The large data output above is literally the output of the query I ran.

  • 2
    What is the query? Is this the output of the query? What is the wanted output, how rows should be "merged"? – ypercubeᵀᴹ Jun 24 '16 at 8:43
  • ill edit the question now for you thanks. – sqlNeeder123 Jun 24 '16 at 8:47
  • 1
    Shouldn't it be bike bike 2 2 bike 6 6? Question remains vague. How about the SQL you use to get this result? What database do you use? How about when one null would hold a value? Which one to take? – Marco Jun 24 '16 at 8:51

It's difficult without seeing your query, but you want to aggregate on your fields with null values if you want to remove the redundant rows.

This query would give you one row of data in this example, I'm not sure how you mean to get your output where you are removing two rows.

    ,MAX(Field3) Field3
    ,MAX(Field4) Field4
    ,MAX(Field6) Field6
    ,MAX(Field7) Field7
FROM TableName

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