最基础最简单SQL语句.doc
文本预览下载声明
/*create table s
( sn char(20) ,
sno char(8) ,
sex char(2) check(sex=男or sex=女),
age int check (age=18 and age=25)
)
create table c
( sno char(20) primary key,
cn char(20) unique,
cno char(10) not null,
score int check (score=0 and score=100)
)
alter table s
add dept char(20)
alter table s
add sno char primary key ?
select sn,sno
from s
select *
from s
select sn, 2010-age
from s
select sn as 姓名,
2010-age as 出生年份
from s
select distinct dept
from s
select sno,score
from c
where cno=1002
select sno,cno,score
from c
where score=85
select sno,cno,score
from c
where score85
select sn,dept,age
from s
where age=19 and age=23
select sn,dept,age
from s
where between19 and 23 ?
select sn,dept, age
from s
where age18 or age23
select sn,sex
from s
where dept in(a,b)
select sn,sex
from s
where dept=a or dept=b
select *
from s
where sn like张%
select *
from s
where sn like_四
create table sc
(
sno char(8),
cno char(10),
sn char(20),
cn char(20),
score int
)
select sno,cno,cn,score
from c
where (cno=1001 or cno=1002)
and score=80
select cno as 学号,
count(sno) as 选课人数
from c
group by cno
select sno,cn,cno
from c
where (cno=1001 or cno=1002)
and score=80
order by cno desc
select *
from c
order by sno,
score desc ?
select top 5 score
from c
order by score desc
select *
from c
order by sn,
score desc
*/
显示全部