TAILIEUCHUNG - Using SQL phần 3

Figure : Using the DISTINCT keyword to retrieve distinct Country column values As you can see, the SELECT statement only displays Country column values that are unique: duplicate values are eliminated. | Figure Using the DISTINCT keyword to retrieve distinct Country column values As you can see the SELECT statement only displays Country column values that are unique duplicate values are eliminated. If you didn t include the DISTINCT keyword then all the Country column values would be displayed. Combining Retrieved Rows From SELECT Statements You use the UNION operator to combine retrieved rows from SELECT statements into one set of rows. For example the following SELECT statement uses the UNION operator to combine the retrieved rows from two SELECT statements that retrieve rows from the Products table the first retrieves rows where the ProductID is less than or equal to 5 and the second retrieves rows where the ProductName starts with Queso SELECT ProductID ProductName QuantityPerUnit UnitPrice FROM Products WHERE ProductID 5 UNION SELECT ProductID ProductName QuantityPerUnit UnitPrice FROM Products WHERE ProductName LIKE Queso Figure shows the results of this statement. Figure Using the UNION operator to combine retrieved rows from two SELECT statements Dividing Retrieved Rows into Blocks You use the GROUP BY clause to divide retrieved rows into blocks. You can think of a block as a group of rows that have been condensed into one row. For example let s say you grouped the SupplierID column of the rows from the Products table. You would get one row for every row that had the same SupplierID column value. The following SELECT statement uses the GROUP BY clause to divide the SupplierID column values into blocks SELECT SupplierID FROM Products GROUP BY SupplierID This SELECT statement displays one row for each group of rows that have the same SupplierID column value. You can get the number of rows in each block using the COUNT function. COUNT is one of the functions that come built into SQL Server and is known as an aggregate function because it can operate on more than one row at a time. You use COUNT to get the number of rows as shown in the following

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.