SQL Column compare in the same table (self-join) -
i need hint in order solve sql (self-join) problem:
a table, columns value
, category
id || value || category || foo ------------------------------------ 1 || 1 || || 1 2 || 2 || || 4 3 || 3 || || 2 4 || 0 || b || 2 5 || 1 || b || 1 6 || 2 || b || 4 7 || 3 || b || 2 8 || 4 || b || 2 9 || 5 || b || 1 10 || 5 || b || 4 11 || 6 || b || 2 12 || 99 || z || 2
i compare values category b
, values category a
, values in b
, not in a
or id
, so:
(0,1,2,3,4,5,5,6) "compare" (1,2,3) => (0,4,5,5,6)
ansi sql:
select * tbl category = 'b' , value not in (select value tbl category = 'a')
see live here.
Comments
Post a Comment