Joe Celko s SQL for Smarties - Advanced SQL Programming P61

Joe Celko s SQL for Smarties - Advanced SQL Programming P61. 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. | 572 CHAPTER 24 REGIONS RUNS GAPS SEQUENCES AND SERIES AND 1 SELECT DISTINCT FROM Cover AS C1 WHERE NOT EXISTS SELECT FROM Cover AS C2 WHERE AND AND OR ORDER BY Finally try this approach. Assume we have the usual Sequence auxiliary table. Now we find all the holes in the range of the intervals and put them in a view or a with clause-derived table. CREATE VIEW Holes hole AS SELECT seq_nbr FROM Sequence WHERE seq_nbr SELECT MAX y FROM Intervals AND NOT EXISTS SELECT FROM Intervals WHERE seq_nbr BETWEEN x AND y UNION VALUES 0 left sentinel value UNION SELECT MAX y 1 FROM Intervals -- right sentinel value The query picks start and end pairs that are on the edge of a hole and counts the number of holes inside that range. Covering has no holes inside its range. SELECT FROM Intervals AS Starts Intervals AS Ends Sequence AS S -- usual auxiliary table WHERE BETWEEN AND -- restrict seq_nbr numbers AND SELECT MAX hole FROM Holes AND NOT IN SELECT hole FROM Holes -- not a hole Coverings 573 AND - 1 IN SELECT hole FROM Holes on a left cusp AND 1 IN SELECT hole FROM Holes on a right cusp GROUP BY HAVING COUNT DISTINCT seq_nbr - 1 -- no .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
Đã 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.