- 1、本文档共21页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
数据库系统原理与应用(SQL Server 2005)课后实训题SQL语句
数据库系统原理与应用(SQL Server 2005)课后实训题SQL语句
--实训4-1
--1
SELECT g_Name,t_ID,g_Price*g_Number
FROM Goods
--2
SELECT g_Name,g_ID,g_Price*g_Number
FROM Goods
--3
SELECT g_Name 商品名称,g_ID 商品编号,g_Price*g_Number 总价值
FROM Goods
--4
SELECT *
FROM Goods
WHERE g_status=热点
--5
SELECT g_Name 商品名称,g_ID 商品编号,g_Price 商品价格,t_ID 商品类别号
FROM Goods
WHERE t_ID=01 AND g_Price2500
--6
SELECT c_CardID,c_Name,c_Gender,c_Address,year(getdate())-year(c_Birth) c_age
FROM Customers
WHERE c_Address like 湖南%AND c_Gender=男AND year(getdate())-year(c_Birth) =30
--7
SELECT c_Name,c_Address,year(getdate())-year(c_Birth) N1
FROM Customers
WHERE year(getdate())-year(c_Birth)=20 and year(getdate())-year(c_Birth)=25
--8
SELECT c_Name,c_Address,year(getdate())-year(c_Birth) N1
FROM Customers
WHERE year(getdate())-year(c_Birth)=20 OR year(getdate())-year(c_Birth)=25
--9
SELECT *
FROM Customers
WHERE c_Address like 湖南%
--10
SELECT *
FROM Customers
WHERE not c_Address like 湖南%
--11
SELECT *
FROM Goods
WHERE g_Name like 三星%
--12
SELECT c_Name,c_TrueName,c_Mobile,c_Email
FROM Customers
WHERE c_TrueName like 黄_
--13
SELECT *
FROM Goods
WHERE g_Image=null
--14
SELECT DISTINCT Orders.c_ID
FROM Customers
join orders
on Customers.c_ID=Orders.c_ID
--15
SELECT TOP 8*
FROM Goods
--16
SELECT g_ID,g_Name,g_Price
FROM Goods
WHERE t_ID=01
order by g_Price desc
--17
SELECT g_ID,g_Name,g_Price,t_ID
FROM Goods
WHERE g_Price 2500
order by t_ID asc ,g_Price desc
--18
SELECT t_ID,g_Number
FROM Goods
ORDER BY t_ID
COMPUTE SUM (g_NUMBER) BY t_ID
--19
SELECT o_ID,o_Sum
FROM orders
order by o_Sum asc
--20
SELECT o_ID,o_Sum
FROM orders
where o_Sum5000
order by o_Sum asc
--21
SELECT * FROM
( SELECT o_Sum,ROW_NUMBER() OVER(ORDER BY o_Sum asc)AS 行号
FROM Orders
)AS temp
where 行号 between 3 and 5
--4-2.1
select g_id,g_name,t_id
FROM goods
--4-2.2
select goods.g_name,goods.g_price,goods.g_number,orders.o_date
from orderdetails
join goods
on orderdetails.g_id=goods.g_id
join orders
on orderdetails.o_id=orders.o_id
--4-2.3
se
文档评论(0)