I've been slamming my head on this problem and viewed a few similar situations on stack exchange and the more I read the more confused I get! I have a table that has the following:
id | zipcode | provider | channel
---------------------------------
1 | 91773 | 342 | 0
2 | 91773 | 2261 | 177
3 | 91773 | 5590 | 0
4 | 91773 | 5590 | 0
5 | 91773 | 5590 | 135
6 | 91773 | 5590 | 0
7 | 91773 | 6010 | 0
8 | 91773 | 6010 | 0
I want to keep only one record and if the channel has anything but a 0 then we keep it. So it should return this:
id | zipcode | provider | channel
---------------------------------
1 | 91773 | 342 | 0
2 | 91773 | 2261 | 177
5 | 91773 | 5590 | 135
8 | 91773 | 6010 | 0
I tried quite a few queries, but none worked. Thanks in advance.
Edit: I've tried some of the examples given, but none seem to give back the correct info, a better example would be to use these and you can see why: insert into unicorns values
(1, 91773, 342, 0),
(2, 91773, 2261, 177),
(3, 91773, 5590, 0),
(4, 91773, 5590, 0),
(5, 91773, 5590, 135),
(6, 91773, 5590, 0),
(7, 91773, 6010, 0),
(8, 91773, 6010, 0),
(9, 91776, 5590, 135),
(10, 91776, 5590, 0),
(11, 91776, 6010, 0),
(12, 91776, 6010, 0);