这是查询,如何从结果中选择前1名?这是针对 SQL Server 的。
SELECT column1
FROM table
WHERE column2 = 'Whatever' AND column3 = 'Sure'
UNION
SELECT column4
FROM table
WHERE column2 = 'Whatever' AND column3 = 'Sure'
最佳答案
试试这个:
SELECT TOP 1 * FROM
(
SELECT column1 FROM table WHERE column2 = 'Whatever' AND column3 = 'Sure'
UNION
SELECT column4 FROM table WHERE column2 = 'Whatever' AND column3 = 'Sure'
) R
ORDER BY Column1
关于sql-server - 如何从 2 列的 UNION 中获取 TOP 1 值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10165823/