zoukankan      html  css  js  c++  java
  • Teach Yourself SQL in 10 Minutes

    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;

  • 相关阅读:
    栈及练习
    约瑟夫问题
    双向链表
    链表
    线性表
    高级排序
    建议16:比较函数调用模式
    建议15:推荐动态调用函数
    建议14:灵活使用Arguments
    建议13:禁用Function构造函数
  • 原文地址:https://www.cnblogs.com/balian/p/13069588.html
Copyright © 2011-2022 走看看