sql
1. 创建视图V_SupplyCount,显示供应商编号,以及该供应商供应的产品的品种数(非CategoryID),该视图包含两个字段:SupplierID、ProductCount。
2. 创建视图V_OrderCount,显示顾客编号,顾客所下订单的产品总金额(金额=单价×数量×折扣),该视图包含两个字段:CustomerID,TotalFee。
2. 创建视图V_OrderCount,显示顾客编号,顾客所下订单的产品总金额(金额=单价×数量×折扣),该视图包含两个字段:CustomerID,TotalFee。
SQL查询练习——实验06
Posted on 2008/11/10 19:15
1. 用不相关子查询,查出公司名首字母为’L’的顾客所下订单的产品总数
SQL语句:
2. 用相关子查询,查出公司名首字母为’L’的顾客所下订单的产品总数
SQL语句:
select distinct count(ProductID) from orderdetails where exists
(select * from orders where OrderID=orderdetails.OrderID and exists
(select * from customers where CustomerID=orders.CustomerID and CompanyName like 'L%'))
SQL语句:
select distinct count(ProductID) from orderdetails where OrderID in
(select OrderID from orders where CustomerID in
(select CustomerID from customers where CompanyName like 'L%'))
(select OrderID from orders where CustomerID in
(select CustomerID from customers where CompanyName like 'L%'))
2. 用相关子查询,查出公司名首字母为’L’的顾客所下订单的产品总数
SQL语句:
select distinct count(ProductID) from orderdetails where exists
(select * from orders where OrderID=orderdetails.OrderID and exists
(select * from customers where CustomerID=orders.CustomerID and CompanyName like 'L%'))
SQL查询练习——实验05
Posted on 2008/11/10 19:12
1. 查询顾客表(Customer)中没有设定区域的顾客编号和公司名
SQL语句:
2. 统计职工表(Employees)中头衔的数量
SQL语句:
3. 查找订单表(Orders)中顾客编号为’VICTE’和’WELLI’的的订单号和运费,并按照运费的降序排列
SQL语句:
4. 查找产品表(Products)中的平均库存总价(库存总价=单价×库存数)
SQL语句:
SQL语句:
select CustomerID,CompanyName from customers where Region is NULL
2. 统计职工表(Employees)中头衔的数量
SQL语句:
select distinct Title from Employees
3. 查找订单表(Orders)中顾客编号为’VICTE’和’WELLI’的的订单号和运费,并按照运费的降序排列
SQL语句:
select OrderID,Freight from orders where CustomerID in ('VICTE','WELLI') order by Freight DESC
4. 查找产品表(Products)中的平均库存总价(库存总价=单价×库存数)
SQL语句:
select avg(UnitPrice*UnitsInStock) from products
停止/启动SQL SERVER和IIS的批处理
Posted on 2008/11/6 21:49
Start SQL SERVER & IIS
@echo.Starting SQL SERVER & IIS......
@echo off
@sc start MSSQLSERVER
@sc start SQLSERVERAGENT
@sc start MSSQLServerOLAPService
@sc start msftesql
@sc start MsDtsServer
@sc start SQLWriter
@iisreset /start
@echo off
@echo.Done!
@pause
Stop SQL SERVER & IIS
@echo.Stopping SQL SERVER & IIS......
@echo off
@sc stop SQLSERVERAGENT
@sc stop MSSQLServerOLAPService
@sc stop msftesql
@sc stop MsDtsServer
@sc stop SQLWriter
@sc stop MSSQLSERVER
@iisreset /stop
@echo off
@echo.Done!
@pause
下载文件 (已下载 94 次)
@echo.Starting SQL SERVER & IIS......
@echo off
@sc start MSSQLSERVER
@sc start SQLSERVERAGENT
@sc start MSSQLServerOLAPService
@sc start msftesql
@sc start MsDtsServer
@sc start SQLWriter
@iisreset /start
@echo off
@echo.Done!
@pause
Stop SQL SERVER & IIS
@echo.Stopping SQL SERVER & IIS......
@echo off
@sc stop SQLSERVERAGENT
@sc stop MSSQLServerOLAPService
@sc stop msftesql
@sc stop MsDtsServer
@sc stop SQLWriter
@sc stop MSSQLSERVER
@iisreset /stop
@echo off
@echo.Done!
@pause
下载文件 (已下载 94 次)SQL查询练习--新实验04
Posted on 2008/11/4 17:14
1. 在产品表(Products)中找出库存大于30的产品的所有信息
SQL语句:
2. 查询顾客表(Customers)中所有不重复的所在城市
SQL语句:
3. 在订单表(Orders)中找出运费在10到50之间的订单编号、顾客编号和职员编号
SQL语句:
4. 在顾客表(Customers)中找出所在城市为London的联系人名和公司名
SQL语句:
5. 在顾客表(Customers)中找出所在城市为London、Madrid、Torino和Paris的顾客编号及电话
SQL语句:
6. 在订单表(Orders)中找出国籍不是Brazil、Spain和Mexico的订单编号和订货日期
SQL语句:
7. 在产品表(Products)中找出单位数量中有box的产品名和产品编号
SQL语句:
8. 在顾客表(Customers)中找出公司名的首字母为F的顾客编号和联系人名
SQL语句:
9. 在顾客表(Customers)中找出公司名的首字母为F,第5位为k的顾客编号和联系人名
SQL语句:
SQL语句:
select * from products where UnitsInStock>30
2. 查询顾客表(Customers)中所有不重复的所在城市
SQL语句:
select distinct city from customers
3. 在订单表(Orders)中找出运费在10到50之间的订单编号、顾客编号和职员编号
SQL语句:
select OrderID,CustomerID,EmployeeID from orders where Freight between 10 and 50
4. 在顾客表(Customers)中找出所在城市为London的联系人名和公司名
SQL语句:
select ContactName,CompanyName from Customers where City='London'
5. 在顾客表(Customers)中找出所在城市为London、Madrid、Torino和Paris的顾客编号及电话
SQL语句:
select CustomerID,Phone from Customers where City in ('London','Madrid','Torino','Paris')
6. 在订单表(Orders)中找出国籍不是Brazil、Spain和Mexico的订单编号和订货日期
SQL语句:
select OrderID,OrderDate from Orders where ShipCountry not in ('Brazil','Spain','Mexico')
7. 在产品表(Products)中找出单位数量中有box的产品名和产品编号
SQL语句:
select ProductName,ProductID from Products where QuantityPerUnit like '%box%'
8. 在顾客表(Customers)中找出公司名的首字母为F的顾客编号和联系人名
SQL语句:
select CustomerID,ContactName from Customers where CompanyName like 'F%'
9. 在顾客表(Customers)中找出公司名的首字母为F,第5位为k的顾客编号和联系人名
SQL语句:
select CustomerID,ContactName from Customers where CompanyName like 'F___k%'




