我需要从我的问题库中随机提问。我有一个表tbl_mq
,其中包含mq_id
列,课程,单元,问题,标记。我需要随机化,使得标记的总和为20。
在这里我尝试了:
Select *
from tbl_mq
where sum(marks)=20
order by rand()
示例:
22, '3CA1151', 'I', 'Fisrt question', 5
20, '3CA1151', 'I', 'Second question', 10
15, '3CA1151', 'I', 'Thisrd question', 10
24, '3CA1151', 'I', '4th question', 5
13, '3CA1151', 'I', 'jyuyt', 10
14, '3CA1151', 'I', 'fghfgh', 12
结果应为
22, '3CA1151', 'I', 'Fisrt question', 5
20, '3CA1151', 'I', 'Second question', 10
24, '3CA1151', 'I', '4th question', 5
or
20, '3CA1151', 'I', 'Second question', 10
15, '3CA1151', 'I', 'Thisrd question', 10
最后我需要一些问题,使得该列的总分为20分。任何人都可以帮忙吗?