TAILIEUCHUNG - Microsoft SQL Server 2000 Programming by Example phần 3

Thương hiệu Tất cả các điều khoản Đề cập trong cuốn sách này đó là Được biết đến là thương hiệu hay nhãn hiệu dịch vụ một cách thích hợp có Been tận. Tổng công ty không thể chứng thực tính chính xác của thông tin này. Trong một chỉ số nhóm, các trang dữ liệu thực tế là mức độ lá của chỉ số, dữ liệu được Đã Bởi vì theo thứ tự. | Chapter 4. Querying and Modifying Data 0 UTPUT 40 9 1937-09-19 00 00 3119 The DISTINCT keyword can be used in any aggregate function to consider repeating values just once. For example to retrieve how many different titles the Employees table has you can use the COUNT aggregate function with the DISTINCT keyword as shown in Listing . In this case the DISTINCT keyword is needed because more than one employee has the same title and you want to count each title once to see how many different titles are in this table. Listing Using DISTINCT in Aggregate Functions EXAMPLE USE Northwind SELECT COUNT DISTINCT title FROM Employees GO 0 UTPUT 4 You use the GROUP BY clause to group rows in a result set generating a summary row for each group of data. All columns specified in SELECT must also be specified in GROUP BY. However columns specified in the GROUP BY clause don t have to be in the SELECT column list. 127 Microsoft SQL Server 2000 Programming by Example To illustrate Listing shows an example that retrieves the number of employees per title. SQL Server generates a row per each title this is the column specified in the GROUP BY clause and counts the number of rows per title. Listing Using the GROUP BY Clause EXAMPLE USE Northwind SELECT title COUNT FROM Employees GROUP BY title GO title Inside Sales Coordinator 1 Sales Manager 1 Sales Representative 6 Vice President Sales 1 4 row s affected It might be necessary to generate a summary row for a table just one row and not a row for each group . In this case because it is just one group the whole table use aggregate functions without the GROUP BY clause as previously shown in Listing . Moreover you can use more than one aggregate function in the same query. For example to get the most recent date in which an order was placed and the minimum orderid in the Orders table use the query shown in Listing . Listing Summarizing Data EXAMPLE USE Northwind SELECT MAX orderdate MIN .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.