时间:2011-01-06 17:09:33

标签: sql sql-order-by case

3 个答案:

答案 0 :(得分:2)

答案 1 :(得分:1)

答案 2 :(得分:0)

SELECT *
FROM
    (
    SELECT *,
        CASE
        WHEN type = 'Classroom' THEN 1
        WHEN type = 'Computer laboratory' THEN 2
        WHEN type = 'Lecture Hall' THEN 3
        WHEN type = 'Auditorium' THEN 4
        END AS ClassTypeValue
    FROM rooms
    ) t
ORDER BY ClassTypeValue, maxppl, roomID

这是我使用的最终查询。谢谢大家帮助我并向我解释。