-7

我有一张如下表。

它存储学生的详细信息。

我想要一个 sql 查询来获取 15 到 27 岁之间的学生姓名。

CREATE TABLE Students(Sno       INT NOT NULL PRIMARY KEY AUTO_INCREMENT,
                      Name      VARCHAR(255),
                      Age_Start INT,
                      Grade     VARCHAR(255));


INSERT INTO Students(Name, Age_Start, Grade)
              VALUES('Student 1', 10, 'Grade A'),
                    ('Student 2', 15, 'Grade B'),
                    ('Student 3', 18, 'Grade C'),
                    ('Student 4', 21, 'Grade D'),
                    ('Student 5', 24, 'Grade E'),
                    ('Student 5', 27, 'Grade F'),
                    ('Student 5', 30, 'Grade G');

输出

 
  学生的姓名
  学生 2
  学生 3
  学生 4
  学生 5

提前致谢

4

2 回答 2

1
select distinct Name as `Students Name`
 from Students
where Age_Start between 15 and 27


SQL Fiddle 演示

于 2012-10-09T07:35:05.950 回答
1
Select distinct Name as `Students Name` 
from Students 
where Age_Start between 15 and 27
于 2012-10-09T07:38:00.610 回答