Running MYSQL 5.5 and trying to essentially return only 1 record from each of the conditions in my IN
clause. I can't use the DISTINCT
because there should be multiple distinct records that are attached to each code (namely cost will be different) from the IN
clause. Below is a dummy query of what I was trying to do, but doesn't work in 5.5 because of the ROW_NUMBER() function.
'1b' may have multiple records with differing cost
values. title
should always be the same across every record with the same codes
value.
Any thoughts?
SELECT codes, name_place, title, cost
FROM (
SELECT *, ROW_NUMBER() OVER(PARTITION BY codes) rn
FROM MyDB.MyTable
)
WHERE codes IN ('1b', '1c', '1d', '1e')
AND rn = 1;