Answer the question
In order to leave comments, you need to log in
Complex query in SQL with a condition? Is it possible?
I write the following query (simplified here):
SELECT
`name`,
(SELECT `value` FROM `t` ORDER BY `value` DESC LIMIT 1,1) AS `second_value`,
FROM `t`;
Answer the question
In order to leave comments, you need to log in
There is a function IFNULL , you can pass two subqueries to it.
True, the solution gives some kind of curvature.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question