本系列传送门:
- 实验二 SQL Server SSMS工具创建和管理数据库及数据表
- 实验三 SQL Server SSMS工具添加数据
- 实验四 SQL的数据定义语句
- 实验五 数据库完整性约束的实现与验证
- 实验六 SQL数据查询实验
- 实验六(2) SQL数据查询—连接查询
- 实验七 SQL的数据更新和视图
- 实验八 T_SQL编程
- 实验九 存储过程和触发器
- 实验十 索引和数据库的安全性
请参考 实验三 SQL Server SSMS工具添加数据 中的数据导入脚本
1、掌握where、order by、group by等子句的含义、作用和语法格式
2、掌握top、distinct、like、in、as等查询关键字的含义、作用和语法格式
3、掌握比较运算符、逻辑运算符、范围运算符等的含义和作用
4、掌握count、max、min、avg等聚集函数的含义和作用
5、理解单表查询、连接查询、子查询、外部查询等语句的含义和语法格式
6、以“电子商务系统”数据库为例,熟练运用SQL数据查询语句完成各类查询问题的求解
select * from supplier;
select catno as '类别编号', catname as '类别名称', describe as '描述'
from category
select proname, price
from product
where catno = 201 and price >1299
select max(price) as '最高价', min(price) as '最低价', avg(price) as '平均价'
from product
where catno = 401
select proname,stock,supname,price,cost,ontime from product
left join supplier
on product.supno = supplier.supno
select supname from product
left join supplier
on product.supno = supplier.supno
where product.proname like '%得力%' or proname like '%考勤机%';
select top 10 *
from orders
left join product
on product.prono = orders.prono
where catno in (
select catno from category
where catname = '手机'
) order by qty desc
select proname, price, cost, stock
from product
left join category
on category.catno = product.catno
where catname = '笔记本电脑' and price >=3000 and price <=5000
select sum(qty) from orders
left join product
on product.prono = orders.prono
left join category
on product.catno = category.catno
where catname = '手机' and
orderdate>= '2021-11-11 00:00:00.000' and orderdate<'2021-11-11 23:59:59.999';
select supname, proname
from product
left join supplier
on supplier.supno = product.supno
由 @kkkkkba 友情提供。
select * from supplier;
select supname,telephone from supplier
select catno as '类别编号', caname as '类别名称', describe as '描述' from category
select top 5 * from product
select distinct empno from employee
select prono,proname,price
from product
order by price asc
select prono,proname,supno
from product
where porno=0
select proname,price
from product
where catno=201 and price>1299
select catno,sum(stock) as 'stock'
from product
group by catno
select max(price),min(price),avg(price)
from product where prono=401