如何从成绩和学生表中找到成绩和学生姓名

时间:2016-06-29 14:48:03

标签: sql

我有一个Student表,其中包含以下列

Student_id|Marks
9|90
1|37

Grade_discription

Min_Score|Max_Score|Grade

0|30|c
31|60|B
61|90|A

我想要输出

Student_id|Grade

1 |B

1 个答案:

答案 0 :(得分:0)

select s.Student_id, g.Grade
  from Student s join Grade_discription g 
    on s.Marks between g.Min_Score and g.Max_Score
 order by s.Student_id;

<强>输出

Student_id|Grade

1 |B
9 |A