TAILIEUCHUNG - SQL VISUAL QUICKSTART GUIDE- P45

SQL VISUAL QUICKSTART GUIDE- P45:SQL (pronounced es-kyoo-el) is the standard programming language for creating, updating, and retrieving information that is stored in databases. With SQL, you can turn your ordinary questions (“Where do our customers live?”) into statements that your database system can understand (SELECT DISTINCT city, state FROM customers;) | Chapter 15 Listing is a variation of Listing that finds all regions of length 2. See Figure for the result. Note that overlapping subregions are listed. To return regions of length n change the WHERE clause s second condition to AND - n - 1 Listing List all regions of length 2. See Figure for the result. Listing SELECT AS StartReg AS EndReg - 1 AS RegLen FROM temps tl temps t2 WHERE AND - l AND NOT EXISTS SELECT FROM temps t3 WHERE 50 AND BETWEEN AND Finding Sequences Runs and Regions StartReg EndReg Re gLen 4 5 2 5 6 2 l0 ll 2 Figure Result of Listing . 420 SQL Tricks Listing List employees by descending sales. See Figure for the result. Listing SELECT emp_id sales FROM empsales ORDER BY sales DESC emp_id sales E09 900 E02 800 E10 700 E05 700 E01 600 E04 500 E03 500 E06 500 E08 400 E07 300 Figure Result of Listing . Tips You also can use these queries to limit the number of rows affected by an UPDATE or DELETE see Chapter 10 . Some of these queries might be illegal in some contexts such as in subqueries or views see your DBMS documentation. Some of the following examples are based on the ideas in Troels Arvin s Comparison of Different SQL Implementations http db rdbms . Limiting the Number of Rows Returned In practice it s common to use queries that return a certain number n of rows that fall at the top or the bottom of a range specified by an ORDER BY clause. SQL doesn t require an ORDER BY clause but if you omit it the query will return an arbitrary set of rows because SQL doesn t promise to deliver query results in any particular order without an ORDER BY clause . The examples in this section use the table empsales Listing and Figure which lists sales figures by employee. Note that some employees have the same sales amounts. A correct query for the top three salespeople in empsales .

TỪ KHÓA LIÊN QUAN
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.