📄 作业.sql
字号:
--在示例数据库Pubs中执行数据查询,要求如下:
--1、查询Titles表,返回所有royalty列非空的数据行;
--2、查询Titles表,返回advance列值大于7000的行数;
--3、查询Titles表,按照type列进行分组,
--显示每一组中type值、Price的平均值;
--4、查询TitleAuthor表中,按照Title_ID进行分组查询,
--并显示每一组中royaltyper的最大值,
--查询限制条件的要求是:au_id的值必须不以”8”开头,但必须包含字符”8”;
--5、查询Sales表,要求返回ord_date在1993年到1994年之间,
--查询结果按照title_id降序的方式进行显示;
--6、查询Sales表,只返回40%的行;
--7、编写一个查询,找出现有图书的各个类别(不能有重复值)
--8、编写一个查询,找出各个作者所著图书的数量
--9、编写一个查询,显示各个作者的版权费(royaltyper)的总和
--10、编写一个查询,显示sales表中各个Title的数量的平均值
--在示例数据库Northwind中,执行数据查询,要求如下:
--1、在”Suppliers”表中查询,得到不同的地区有多少家供应商的信息;
--2、在”Suppliers”表中查询,显示哪些供应商有传真;
--3、在“Products”表中查询,查询不同产品所订购的总价;
--4、在”Orders”表中查询,查询运货费排名前十位的所有信息;
--1=====================================================================================================
select royalty from titles where royalty is null
--2=====================================================================================================
select advance from titles where advance > 7000
--3=====================================================================================================
select * from titles order by type compute avg(price) by type
select type,avg(price) as 平均值 from titles group by type
--4=====================================================================================================
select * from titleauthor where au_id like '[^8]%8%'
order by title_id compute max(royaltyper)
--5=====================================================================================================
select * from sales where ord_date between '1993' and '1994' order by title_id desc
--6=====================================================================================================
select top 40 percent * from sales
--7=====================================================================================================
select distinct type from titles
--8=====================================================================================================
--9=====================================================================================================
select title_id,sum(royalty) as 总合 from titles group by title_id
--10=====================================================================================================
select count(qty) as 平均值,title_id from sales group by title_id
--1=====================================================================================================
--2=====================================================================================================
select ContactName from Suppliers where Fax is not null
--3=====================================================================================================
--4=====================================================================================================
select top 10 Freight
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -