如何编写单个SQL查询来显示成绩?

时间:2017-06-19 16:14:30

标签: sql sqlite

如果我有一个包含测试分数的表,并且想要编写单个SQL查询来显示成绩

F for scores below 35, 
D for scores 36-50, 
C for scores 51-60, 
B for 61-75, 
A for 76-85, 
A* for 85+, 

我应该如何在linux终端中使用sqlite3。

谢谢:)

1 个答案:

答案 0 :(得分:0)

试试这个: -

可能对你有所帮助

SELECT
     CASE WHEN SCORES < 35 THEN 'F' 
        WHEN SCORES BETWEEN 36 AND 50 THEN 'D' 
        WHEN SCORES BETWEEN 51 AND 60 THEN 'C' 
        WHEN SCORES BETWEEN 61 AND 75 THEN 'B' 
        WHEN SCORES BETWEEN 76 AND 85 THEN 'A'
        WHEN SCORES > 85 THEN 'A+'
        END AS GRADE
FROM TABLE_NAME;