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

Joe Celko s SQL for Smarties - Advanced SQL Programming P37. 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 audience. | 332 CHAPTER 17 THE SELECT STATEMENT SELECT FROM Foobar AS Fl ORDER BY DESC One outcome might have been any of these Result 1 Apples 5 Oranges 5 Apples 2 Banana 2 Apples 1 Result 2 Oranges 5 Apples 5 Apples 2 Banana 2 Apples 1 Result 3 Oranges 5 Apples 5 Banana 2 Apples 2 Apples 1 Result 4 Apples 5 Oranges 5 Banana 2 Apples 2 Apples 1 If you use SELECT FROM Foobar AS F1 ORDER BY DESC ASC Result Apples 5 Oranges 5 o SELECT and JOINs 333 Apples 2 Banana 2 Apples 1 But this is not what we wanted the order within fruits has been destroyed. Likewise SELECT FROM Foobar AS Fl ORDER BY ASC DESC Results Apples 5 Apples 2 Apples 1 Banana 2 Oranges 5 But this is still not what we wanted the order within scores has been destroyed. We need a dummy column to preserve the ordering thus SELECT SELECT MAX score FROM Foobar AS F2 WHERE AS score_preserver FROM Foobar AS Fl ORDER BY score_preserver DESC ASC DESC Cursors include an updatability clause which tells you if the cursor is FOR READ ONLY or for UPDATE OF column name list but this clause in optional. If order by is specified or if the result table is a read-only table then the updatability clause defaults to FOR READ ONLY. The ORDER BY and CASE Expressions SQL-99 allows you to use a function in an order by clause. While it is now legal it is still not a good programming practice. Users should see the fields that are used for the sort so they can use them to read and locate lines of data in reports. The sorting values are usually on the left side of each line since we read left to right. The most portable method is to use a case expression that takes an external parameter of the form 334 CHAPTER 17 THE SELECT STATEMENT SELECT first_name last_name dept CASE flag WHEN f THEN first_name WHEN l THEN last_name WHEN d THEN dept ELSE NULL END AS sort_col FROM Personnel ORDER BY .

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.