TAILIEUCHUNG - Joe Celko s SQL for Smarties - Advanced SQL Programming P56

Joe Celko s SQL for Smarties - Advanced SQL Programming P56. In the SQL database community, Joe Celko is a well-known columnist and purveyor of valuable insights. In Joe Celko's SQL for Smarties: Advanced SQL Programming, he picks up where basic SQL training and experience leaves many database professionals and offers tips, techniques, and explanations that help readers extend their capabilities to top-tier SQL programming. Although Celko denies that the book is about database theory, he nevertheless alludes to theory often to buttress his practical points. This title is not for novices, as the author points out. Instead, its intended. | 522 CHAPTER 23 STATISTICS IN SQL SELECT CASE MOD COUNT 2 WHEN 0 even sized table THEN MIN CASE WHEN THEN ELSE NULL END ELSE odd sized table END FROM Parts AS Pl Parts AS P2 GROUP BY HAVING COUNT CASE WHEN THEN l ELSE NULL END COUNT l 2 This answer is due to Ken Henderson. Celko s Third Median Another approach involves looking at a picture of a line of sorted values and seeing where the median would fall. Every value in the column weight partitions the table into three sections values that are less than weight values that are equal to weight and values that are greater than weight. We can get a profile of each value with a tabular subquery expression. Now the question is how to define a median in terms of the partitions. Clearly the definition of a median means that if lesser greater then weight is the median. Now look at Figure for the other situations. If there are more elements in the greater values than half the size of the table then weight cannot be a median. Likewise if there are more elements in the lesser values than half the size of the table then weight cannot be a median. If lesser equal greater then weight is a left-hand median. Likewise if greater equal lesser then weight is a right-hand median. However if weight is the median then both lesser and greater must have tallies of less than half the size of the table. That translates into the following SQL SELECT AVG DISTINCT weight FROM SELECT SUM CASE WHEN THEN l ELSE 0 END SUM CASE WHEN The Median 523 ---------- Figure Defining a Median. Partition on median Partition too low Two partitions split the median THEN 1 ELSE 0 END SUM CASE WHEN THEN 1 ELSE 0 END FROM Parts AS Pl Parts AS P2 GROUP BY AS Partitions part_nbr weight lesser equal greater WHERE lesser greater OR lesser SELECT COUNT FROM Parts .

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.