标签:width 数据 内连接 top identity 左连接 等等 ble tab
create table student
(
ID int primary key identity(1,1),
studentNo varchar(20) not null,
name varchar(20) not null,
address varchar(20) not null,
year int not null,
)
create table subject
(
ID int primary key identity(1,1),
subjectName varchar(20) not null,
grade decimal(5,2) not null, 成绩
)
和(sum),最大(max),最小(min),where and(条件和),or(条件或) ,=等于,!=不等于
select max(grade )from student 查成绩和
select max(grade )from student 查最大成绩
select avg(grade )from student 查平均数
select min(grade )from student 查最小成绩
select count(*)from student 查成绩总人数
select*from student ID>5 and ID!=6
select*from student ID=4 or ID>9
select top 2* from student 查询表前两条数据
select top 2 ID from student 查询列名ID前两条数据
innert join 内连接,left join 左连接,right join 右连接
select* from student a inner join subject b on a.ID=b.ID
select* from student a left join subject b on a.ID=b.ID
select* from student a right join subject b on a.ID=b.ID
select (可以加查的列名,函数,条件等等) from student a right join subject b on a.ID=b.ID (后面可以加 where ID=ID之类的)
子查询两个案例
标签:width 数据 内连接 top identity 左连接 等等 ble tab
原文地址:https://www.cnblogs.com/howorld/p/14898375.html