a):求年龄在20-30岁之间,张姓学生按年龄升序排序;
b):求有相同年龄学生的全部信息;
请哪位仁兄学姐赐教!!!不胜感激!!!
create table #student(
id int identity(1,1) not null primary key,
name nvarchar(60),
age smallint
)
insert into #student(name,age) values(N'张天',16)
insert into #student(name,age) values(N'李四',24)
insert into #student(name,age) values(N'赵六',31)
insert into #student(name,age) values(N'张七',40)
insert into #student(name,age) values(N'王五',10)
insert into #student(name,age) values(N'陈八',22)
insert into #student(name,age) values(N'马九',16)
insert into #student(name,age) values(N'曾十',24)
--1
select * from #student where age between 20 and 30 order by name asc
--2
select * from #student where age in(select age from #student group by age having count(age)>1) order by id
drop table #student