发现这个语句是错的啊???不能执行
select top 6 * from T_EXAM where type=1 and difficulty=1 and distinguish=1 order by newid()
union all
select top 2 * from T_EXAM where type=2 and difficulty=1 and distinguish=1 order by newid()
union all
select top 5 * from T_EXAM where type=2 and difficulty=2 and distinguish=1 order by newid()
union all
select top 7 * from T_EXAM where type=2 and difficulty=2 and distinguish=2 order by newid()
加了newid()是不行了。
------解决方案--------------------lz要的结果什么?
这样?
SELECT *
FROM ( SELECT TOP 6
*
FROM T_EXAM
WHERE type = 1
AND difficulty = 1
AND distinguish = 1
UNION ALL
SELECT TOP 2
*
FROM T_EXAM
WHERE type = 2
AND difficulty = 1
AND distinguish = 1
UNION ALL
SELECT TOP 5
*
FROM T_EXAM
WHERE type = 2
AND difficulty = 2
AND distinguish = 1
UNION ALL
SELECT TOP 7
*
FROM T_EXAM
WHERE