首页 > Code > SQL查询练习–新实验04

SQL查询练习–新实验04

2008年11月5日 timmy 发表评论 阅读评论 357 views

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%'

若日志经rss订阅或导入到外站,可能有些视频和图片无法显示,请点击原文链接查看。
本文链接地址: http://imtimmy.com/sql%e6%9f%a5%e8%af%a2%e7%bb%83%e4%b9%a0%e6%96%b0%e5%ae%9e%e9%aa%8c04/

转载请注明: 转载自Timmy's Blog

如果你觉得本博内容不错,欢迎 [订阅 Timmy's Blog],以便第一时间了解本博更新内容;


不妨再看看这些相关的日志:

  1. SQL查询练习——实验06
  2. 实验07——SQL练习
  3. SQL查询练习——实验05
  4. mssql server查询指定行数的记录(用于分页记录)
  5. 实验04 SQL查询练习

分类: Code 标签:
  1. 本文目前尚无任何评论.
  1. 本文目前尚无任何 trackbacks 和 pingbacks.
:wink: :twisted: :roll: :oops: :mrgreen: :lol: :idea: :evil: :cry: :cool: :arrow: :?: :-| :-x :-o :-P :-D :-? :) :( :!: 8-O