我有一个型号Pupil
,其中有score
。我需要用奇怪的规则列表:顺序按分数(DESC),但超过100个应责令为零所有得分(!):特定订单(sql)
Pupil.all(:order => 'score DESC' ...?)
100
86
34
21
6
3
1
0
143
125
354
0
456
0
0
我可以使用红宝石订购它,但我需要的sql
ASLO我可以创建数据库附加字段,用于存储像
new_score = score > 100 ? 0 : score
数据,但我认为我们可以让SQL没有它
什么数据库您使用的? – 2010-11-16 10:29:18
MySQL,sqlite3。 – fl00r 2010-11-16 10:30:54