Select rows with in particular range sql query [cl

2019-09-22 11:57发布

I have a table like below.

It Stores Students Details.

I want a sql query to have students Name who are between age 15 and 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');

Output

 
  Students Name
  Student 2
  Student 3
  Student 4
  Student 5

Thanks in Advance

标签: mysql sql
2条回答
小情绪 Triste *
2楼-- · 2019-09-22 12:19
Select distinct Name as `Students Name` 
from Students 
where Age_Start between 15 and 27
查看更多
不美不萌又怎样
3楼-- · 2019-09-22 12:21
select distinct Name as `Students Name`
 from Students
where Age_Start between 15 and 27


SQL Fiddle demo

查看更多
登录 后发表回答