Skip to content

Instantly share code, notes, and snippets.

@MartelliEnrico
Last active October 26, 2016 08:19
Show Gist options
  • Save MartelliEnrico/31db589d3ad51ce66525562cb45112f0 to your computer and use it in GitHub Desktop.
Save MartelliEnrico/31db589d3ad51ce66525562cb45112f0 to your computer and use it in GitHub Desktop.
SELECT Tax
FROM (
SELECT Bookings.Tax AS Tax
FROM Bookings
JOIN Field
ON Bookings.Code = Field.Code
WHERE Field.IsCovered = 0
GROUP BY Tax
HAVING COUNT(Tax) >= 2
)
WHERE Tax NOT IN (
SELECT DISTINCT Bookings.Tax AS Tax
FROM Bookings
JOIN Field
ON Bookings.Code = Field.Code
WHERE Field.IsCovered = 1
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment