I have the following table and data:
DECLARE @Temp TABLE (id int, city varchar(10), ref varchar(10))
INSERT INTO @Temp (id, city, ref)
SELECT 1, 'London', 'GBP' UNION ALL
SELECT 2, 'London', 'EUR'
SELECT *
FROM @Temp
WHERE ((city = 'London' AND ref = 'GBP') OR (city = 'London' AND ref <> 'GBP'))
This returns:
1 London GBP
2 London EUR
What I would like to do is to check for where city = 'London' AND ref = 'GBP' first, if there is no row qualifying this then check if the city is London and ref can be anything, tried using case when but did not quite work.
In this scenario I should only get the row #1.
Thanks