Pages: 1/1 First page 1 Final page [ View by Articles | List ]

SQL查询练习--新实验04

| November 4, 2008 17:14 | timmy | Via Original
1.  在产品表(Products)中找出库存大于30的产品的所有信息
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%'
Tags:
Pages: 1/1 First page 1 Final page [ View by Articles | List ]