我需要在单个表格中选择最大(时间)和一些特定时间。我试过这样的事情。任何想法?
SELECT * FROM ara WHERE date = '2017-03-31' and time in('07:00:00','13:00:00','19:00:00',max(tme)) order by time desc
SELECT * FROM ara WHERE date = '2017-03-31' and (time = '07:00:00' or time = '13:00:00' or time = '19:00:00'or time = max(time)) order by time desc
答案 0 :(得分:2)
假设您从同一个ara
表中选择了最长时间,您可以这样做
SELECT *
FROM ara
WHERE date = '2017-03-31' and
(
time in ('07:00:00','13:00:00','19:00:00') OR
time = (SELECT MAX(time) FROM ara)
)
ORDER BY time desc