SQL Server 2008

Page 1

2.txt 1. 在資料表ord中,找出1986年7月份有多少筆訂單 +--------+ | 總筆數 | +--------+ | 4 | +--------+ ANS: SELECT COUNT(*) AS '總筆數' FROM ORD WHERE ORDERDATE BETWEEN '1986/7/1' AND '1986/7/31'; 2. 在資料表ord中,找出1986年7月份訂單的總金額 +---------+ | 總金額 | +---------+ | 8368.20 | +---------+ ANS: SELECT SUM(TOTAL) AS '總金額' FROM ORD WHERE ORDERDATE BETWEEN '1986/7/1' AND '1986/7/31'; 3. 在資料表ord中,找出1986年7月份訂單中最大筆的金額是多少 +----------+ | 最大金額 +----------+ | 8324.00 | +----------+

|

ANS: SELECT MAX(TOTAL) AS '最大金額' FROM ORD WHERE ORDERDATE BETWEEN '1986/7/1' AND '1986/7/31';

綜合3項 select COUNT(*) as '總比數', SUM(total) as '總金額', MAX(total) as '最大金額', avg(total) as '平均' from ORD where ORDERDATE between '1986/7/1' and '1986/7/31';

第 1 頁


Turn static files into dynamic content formats.

Create a flipbook
Issuu converts static files into: digital portfolios, online yearbooks, online catalogs, digital photo albums and more. Sign up and create your flipbook.