1. 程式人生 > >sql複習1

sql複習1

1.SELECT store_name FROM Store_Information 2.SELECT DISTINCT store_name FROM Store_Information

3.SELECT store_name FROM Store_Information WHERE Sales > 1000

4.SELECT store_name FROM Store_Information WHERE Sales > 1000 OR (Sales < 500 AND Sales > 275)

5.SELECT * FROM Store_Information WHERE store_name IN (‘Los Angeles’, ‘San Diego’)

6.SELECT * FROM Store_Information WHERE Date BETWEEN ‘Jan-06-1999’ AND ‘Jan-10-1999’

7.SELECT * FROM Store_Information WHERE store_name LIKE ‘%AN%’

8.SELECT store_name, Sales, Date FROM Store_Information ORDER BY Sales DESC

9.SELECT store_name, Sales, Date FROM Store_Information ORDER BY 2 DESC

10.SELECT SUM(Sales) FROM Store_Information 【注】基本函式: AVG (平均) COUNT (計數) MAX (最大值) MIN (最小值) SUM (總合)

11.SELECT COUNT(store_name) FROM Store_Information WHERE store_name is not NULL

12.SELECT COUNT(DISTINCT store_name) FROM Store_Information

13.SELECT store_name, SUM(Sales) FROM Store_Information GROUP BY store_name

14.SELECT store_name, SUM(sales) FROM Store_Information GROUP BY store_name HAVING SUM(sales) > 1500