select top 500 * from tb where id = 600 union --all 不去重复 select top 2 * from tb where class < 20
select top(100) from tb where id=600 union select top(2) from tb where class<20
union后面加了all就把重复行也显示出来
select top(10) from tb where id=600 union --自动去重 select top(2) from tb where class<20
--SELECT * FORM article where ID=600 OR CLASS<20 --现在想写成ID=600 的取top 100 --CLASS<20 的取top 2 SELECT top 100 * FROM article WHERE ID=600 UNION SELECT top 2 * FROM article WHERE CLASS<20
这个没办法case when。别想了
select top 500 * from tb where id = 600
union --all 不去重复
select top 2 * from tb where class < 20
union
select top(2) from tb where class<20
union后面加了all就把重复行也显示出来
select top(10) from tb where id=600
union --自动去重
select top(2) from tb where class<20
--SELECT * FORM article where ID=600 OR CLASS<20
--现在想写成ID=600 的取top 100
--CLASS<20 的取top 2
SELECT top 100 * FROM article
WHERE ID=600
UNION
SELECT top 2 * FROM article
WHERE CLASS<20