I have two equal queries whit different filter applied on the same table.
The first query returns (1,2,3,4,5) and the second returns (3,4,5).
I want apply the MINUS/EXCEPT operator:
select1 minus select2 = (1,2)
How should I implements this logic using firebird SQL dialect ? (I'm using superserver v2.1)
I'm getting the opposite results performing
select1 UNION select2 = (1,2,3,4,5)
thanks
The MINUS operator does not exist in Firebird. The closest approximation I can think of is something like the example below. This uses Common Table Expressions, introduced in Firebird 2.1, but could of course also work with subqueries (I just find CTE more readable)
In this query I use LEFT JOIN to combine
select1andselect2, and then only retain those rows fromselect1that do not occur inselect2.