首页 > 数据库技术 > 详细

Teach Yourself SQL in 10 Minutes - Page 40 – Lesson 4 练习

时间:2020-06-09 00:27:47      阅读:46      评论:0      收藏:0      [点我收藏+]

1. Write a SQL statement to retrieve the product id (prod_id) and name (prod_name) from the Products table, returning only products with a price (prod_price) of 9.49.

SELECT prod_id, prod_name FROM Products WHERE prod_price = 9.49;

2. Write a SQL statement to retrieve the product id (prod_id) and name (prod_name) from the Products table, returning only products with a price (prod_price) of 9 or more.

SELECT prod_id, prod_name FROM Products WHERE prod_price >= 9;

3. Now let’s combine Lessons 3 and 4. Write a SQL statement that retrieves the unique list of order numbers (order_num) from the OrderItems table which contain 100 or more (quantity) of any item.

SELECT DISTINCT order_num FROM OrderItems WHERE quantity >= 100;

4. One more. Write a SQL statement which returns the product name (prod_name) and price (prod_price) from Products table for all products priced between 3 and 6. Oh, and sort the results by price. (There are multiple solutions to this one and we’ll revisit it in the next lesson, but you can solve it using what you’ve learned thus far).

SELECT prod_name, prod_price FROM Products WHERE prod_price BETWEEN 3 AND 6 ORDER BY prod_price;

Teach Yourself SQL in 10 Minutes - Page 40 – Lesson 4 练习

原文:https://www.cnblogs.com/balian/p/13069588.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!