TAILIEUCHUNG - advanced sql Functions in Oracle 10G phần 5

Đầu tiên chúng ta nhìn vào một số sơ bộ đối với mệnh đề GROUP BY. Khi tổng hợp được sử dụng trong một câu lệnh SQL, nó đề cập đến một tập hợp các hàng. Cảm giác của GROUP BY là để tích lũy tổng hợp thiết lập giá trị hàng. Tất nhiên nếu tổng hợp được sử dụng bởi chính nó chỉ có nhóm cấp bảng | The Use of Analytical Functions in Reporting Analytical Functions III We begin by looking a little closer at the use of GROUP BY. GROUP BY First we look at some preliminaries with respect to the GROUP BY clause. When an aggregate is used in a SQL statement it refers to a set of rows. The sense of the GROUP BY is to accumulate the aggregate on row-set values. Of course if the aggregate is used by itself there is only table-level grouping . the group level in the statement SELECT MAX hiredate FROM employee has the highest group level that of the table Employee. The following example illustrates grouping below the table level. Let s revisit our Employee table SELECT FROM employee Which gives EMPNO ENAME HIREDATE ORIG_SALARY CURR_SALARY REGION 101 John ---DEC-97 35000 39000 W 102 Stephanie 22-SEP-98 35000 44000 W 104 Christina 08-MAR-98 43000 55000 W 108 David 37000 39000 E 111 Kate 08-JUL-01 13-APR-00 45000 49000 E 106 Chloe 19-JAN-96 33000 44000 W 122 Lindsey 22-MAY-97 40000 52000 E 150 Chapter I Take a look at this example of using an aggregate with the GROUP BY clause to count by region SELECT count region FROM employee GROUP BY region Which gives COUNT REGION 3 E 4 W Any row-level variable . a column name in the result set must be mentioned in the GROUP BY clause for the query to make sense. In this case the row-level variable is region. If you tried to run the following query which does not have region in a GROUP BY clause you would get an error. SELECT count region FROM employee Would give SELECT count region ERROR at line 1 ORA-00937 not a single-group group function The error occurs because the query asks for an aggregate count and a row-level result region at the same time without specifying that grouping is to take place. GROUP BY may be used on a column without the column name appearing in the result set like this SELECT count FROM employee GROUP BY region 151 The Use of Analytical Functions in Reporting Analytical Functions III Which would give COUNT

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.