select top (50) PaperId from TB_Paper where QuestionTypeId=1 and PaperDegree ='0'
or PaperDegree='1' or PaperDegree='2'
我希望查询出来的结果集中这50条数据
满足PaperDegree ='0'这个条件的占40% 满足PaperDegree='1'这个条件的 的占了 40% 满足PaperDegree='2'这个条件的占了20%
数据量会比较大,我希望写的时候可以考虑到优化。
select top(20) PaperId from TB_Paper where QuestionTypeId=1 and PaperDegree ='0' union all
select top(20) PaperId from TB_Paper where QuestionTypeId=1 and PaperDegree ='1' union all
select top(10) PaperId from TB_Paper where QuestionTypeId=1 and PaperDegree ='2'
这样写,性能应该不至于太差