I have a SELECT query of a table with GROUP BY
id col1 category
1 some 1
2 x 1
3 another 1
4 x 2 // should be removed
5 some 2
6 x 2 // should be removed
7 some 3
8 some 3
9 x 4 // should be removed
10 some 4
11 x 4
12 some 4
I want to SELECT or UPDATE to remove a row if the first or last (with id order) is x
(a given value). In other words, I want to skip the first and last row of a category IF col1='x'
.
I cannot use JOIN
as it is a TEMPORARY
table.
JOIN
ed to itself.col1='x'