Question

I have a join query which returns multiple rows

ID    SearchID   Bool1      Bool2    Bool2
1     1          1          1        0
1     1          0          0        0
5     1          1          0        0
6     1          0          0        0
9     1          0          0        0

The first column ID can be omitted, which leaves us with

SearchID   Bool1      Bool2    Bool2
1          1          1        0
1          0          0        0
1          1          0        0
1          0          0        0
1          0          0        0

Since all the data returned applies to SearchID 1, I would like to end up with a row that will merge the results of all the boolean fields i.e.

SearchID   Bool1      Bool2    Bool2
1          1          1        0

IsButton should be 1 as there was one or more row with 1 AutoRun should be 1 as there was one or more row with 1 IsOnMain should be 0 as there was no rows with 1

but I want handle this for multiple rows that may have been returned and I want to end up with a unique row for each searchid

ID    SearchID   Bool1      Bool2    Bool2
1     1          1          1        0
1     1          0          0        0
5     1          1          0        0
6     1          0          0        0
9     1          0          0        0
3     2          0          0        0
5     2          0          0        0
3     3          0          0        0
9     3          0          0        1
etc...

SearchID   Bool1      Bool2    Bool2
1          1          1        0
2          0          0        0
3          0          0        1
etc...

Am I making sense?

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top