Đang chuẩn bị liên kết để tải về tài liệu:
SQL VISUAL QUICKSTART GUIDE- P13

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

SQL VISUAL QUICKSTART GUIDE- P13: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 4 Sorting Rows with ORDER BY You can sort by the results of expressions Chapter 5 describes how to create expressions by using functions and operators Listing 4.17 and Figure 4.17 . You can intermingle column names relative column positions and expressions in ORDER BY. You should create indexes for columns that you sort frequently see Chapter 12 . The sequence in which unordered rows appear actually is based on the physical order of rows in the DBMS table. You shouldn t rely on physical order because it changes often such as when rows are added updated or deleted or an index is created. Sorting by relative column position is useful in UNION queries see Combining Rows with UNION in Chapter 9. DBMS DBMSs restrict the columns that can appear in an ORDER BY clause depending on data type. For example in Microsoft SQL Server you can t sort by ntext text and image columns and in Oracle you can t sort by blob clob nclob and bfile columns. Search your DBMS documentation for SELECT or ORDER BY. In Microsoft Access you can t use an expression s column alias in ORDER BY. To run Listing 4.17 either retype the expression in the ORDER BY clause ORDER BY price sales DESC or use the relative column position ORDER BY 4 DESC Listing 4.17 This query sorts by an expression. See Figure 4.17 for the result. I ve created a column alias for the expression because it would be cumbersome to repeat the expression in the ORDER BY clause and because it creates a more meaningful column label in the result. Listing SELECT title_id price sales price sales AS Revenue FROM titles ORDER BY Revenue DESC title_id price sales Revenue T07 23.95 1500200 35929790.00 T05 6.95 201440 1400008.00 T12 12.99 100001 1299012.99 T03 39.95 25667 1025396.65 T11 7.99 94123 752042.77 T13 29.99 10467 313905.33 T06 19.95 11320 225834.00 T02 19.95 9566 190841.70 T04 12.99 13001 168882.99 T09 13.95 5000 69750.00 T08 10.00 4095 40950.00 T01 21.99 566 12446.34 T10 NULL NULL NULL Figure 4.17 Result of Listing 4.17. .

Đã 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.