jeudi 10 janvier 2019

Merging similar SQL rows

I want to merge rows base of some IF condition in SQL. My database looks like this

| com_id | bom_id |fil_title
=====================
| 6067   | 6070   |NULL
| 6067   | 6070   |07
| 6067   | 6071   |NULL
| 6067   | 6071   |07
| 6067   | 6069   |NULL

What I want to achieve is

| com_id | bom_id |fil_title
=====================
| 6067   | 6070   |07
| 6067   | 6071   |07
| 6067   | 6069   |NULL

So every time if i had two rows with same bom_id i want to merge them in one, but if I had one just leave it.

It's just a sample - my full query is bigger, but problem is just there. I know that SQL has some IF but I don't know really how to use it here.

Aucun commentaire:

Enregistrer un commentaire