Reputation: 107
I have a database and I want to output the VAL of a row that has a POSITION of 49 with the highest ID. I have this code but I'm not sure where to go from here.
SELECT ID, POSITION,
CASE WHEN POSITION = 49 THEN VAL END
FROM Log
Upvotes: 0
Views: 155
Reputation: 4824
simplest solution would be
SQL-SERVER
SELECT top 1 val
FROM Log
where position = 49
order by id desc
MySQL
SELECT val
FROM Log
where position = 49
order by id desc
limit 1
Upvotes: 2