请教各位大侠,是否有好的办法解决这个问题:关于如何抽题组卷的!

oldsky 2003-05-28 02:54:20
如果要在10万条试题记录中抽取一份试卷,如何去查询?
我的思路是,一个大题一个大题去抽取,比如要抽取知识点(NodeID)为3,题型(StyleID)为4的小题共20道,其难度(Difficulty)比例为【难,3;较难,4;中,6;较易,4;易,3】,如何写SQL语句完成查询?
是否有其它好办法进行组卷?
...全文
57 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
psxfghost 2003-05-28
  • 打赏
  • 举报
回复
try:
declare @num int
select @num=count(*) from table
where nodeid = 3 and styleid = 4 and Difficulty='难'
set @num=cast(@num*rand()+1 as int)
insert into tb_object 字段1,字段2,...(除了id外的所有字段) from (select identity(int,1,1) as id from table where nodeid = 3 and styleid = 4 and Difficulty='难') as a
where case when @num<4 then id between @num and @num+3 else id between @num-3 and @num end --要提多少题就加多少

同理就可以把随机抽取的 较难;中;较易;易 的考题数据插入表tb_object
语法我没试,仅把思路提供,有问题再回帖吧
^_^
zsforever 2003-05-28
  • 打赏
  • 举报
回复
select top 3 * from yourTable where nodeid = 3 and styleid = 4 and Difficulty = 1 order by newid()
union all
select top 4 * from yourTable where nodeid = 3 and styleid = 4 and Difficulty = 2 order by newid()
union all
....
不知道我是否理解你的意思正确
cuiyonggang007 2003-05-28
  • 打赏
  • 举报
回复
先建一个试图:my_view //查出满足知识点和题形的记录集
create view my_view
as
select * from from yourTable where nodeid = 3 and styleid = 4
///////////////////
select top 3 * from my_view where difficulty=1 order by 字段(随机排序标志)
union
select top 4 * from my_view where difficulty=2 order by 字段(随机排序标志)
union
select top 6 * from my_view where difficulty=3 order by 字段(随机排序标志)
union
select top 4 * from my_view where difficulty=4 order by 字段(随机排序标志)
union
select top 3 * from my_view where difficulty=5 order by 字段(随机排序标志)
Varchar 2003-05-28
  • 打赏
  • 举报
回复
select top 3 * from yourTable where nodeid = 3 and styleid = 4 and Difficulty='难'
order by newid()
union all
select top 4 * from yourTable where nodeid = 3 and styleid = 4 and Difficulty='较难'
order by newid()
union all
select top 6 * from yourTable where nodeid = 3 and styleid = 4 and Difficulty='中'
order by newid()
union all
select top 4 * from yourTable where nodeid = 3 and styleid = 4 and Difficulty='较易'
order by newid()
union all
select top 3 * from yourTable where nodeid = 3 and styleid = 4 and Difficulty='易'
order by newid()

oldsky 2003-05-28
  • 打赏
  • 举报
回复
To : zsforever(虎虎)
这个我当然知道写,但是如何抽取难题3道,较难题4道;中等题6道;较易题4道;易题3道。
假设用1-5分别代表从难到易的级别。如何去查?
zsforever 2003-05-28
  • 打赏
  • 举报
回复
select top 20 * from yourTable where nodeid = 3 and styleid = 4 order by newid()

34,838

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧