Reputation: 21
Lets assume you have the following Data:
| COL 1 | COl 2 | COL 3 |
| 10040 | [null] | [null] |
| 10040 | [null] | Y |
| 10040 | Y | [null] |
| 10070 | [null] | [null] |
| 10070 | Y | [null] |
Is there any way using purely SQL to group by "COL 1" and collapse the data down to this:
| COL 1 | COL 2 | COL 3 |
| 10040 | Y | Y |
| 10070 | Y | [null] |
Thanks in advance!
Upvotes: 2
Views: 113
Reputation: 1121
I am not sure if this is what you need, but you can use many ways doing it such as:
There is no simplify then that:
select col1, max(col2), max(col3)
from table
group by col1;
If you like, please comment and I will give you an example with an analytic function such as rank.
Upvotes: 3