1. Trang chủ
  2. » Công Nghệ Thông Tin

The Language of SQL- P46 docx

5 193 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

However, the pivot table also adds some key elements that greatly enhance its usefulness: ■ First, a pivot table is completely interactive. Rather than viewing a static crosstab report, the user can modify the pivot table quickly by rearranging data elements into the various areas: rows, columns, and data. In addition, pivot tables provide a fourth data area called the page, which allows for data items to be used in filtering but not displayed. ■ The data in pivot tables exists as a separate store of data and can even be saved as a separate file. Because the data in a pivot table exists on its own, users can rearrange the data without affecting the data from which the pivot table was created. ■ Pivot tables allow for additional data selection. For example, specific values of various data items can be excluded. Or the aggregated values in the data area of the pivot table can be changed from sums to counts. ■ Pivot tables can add drill-down functionality to the data. For example, if the underlying data contains columns such as country, state, and city , the pivot table can be set up so you can double-click on a country to see all states in that country and then double-click again to see all cities in each state. ■ Pivot tables allow users to drill through from summarized data to the underlying details. Thus, you have the ability to double-click on any individual value in the data area to see the individual rows that contributed to that number. It’s beyond the scope of this book to explore pivot tables in any amount of detail. But an awareness of what you can accomplish with pivot tables can be very useful for the SQL developer. Figure 20.3 shows an example of a pivot table that was created from the same data as listed earlier, but with the addition of two new columns: Date and Subcategory. The Subcategory column is a further breakdown of the product category. In this pivot table, the date, product category, and subcategory were all put in the rows area. This illustrates how pivot tables can provide a further breakdown of data in a very flexible manner. Spreadsheets and Pivot Tables 211 Figure 20.3 Pivot table. The important point about this pivot table is that there are three different levels of groups in the rows. First, it divides all data by date, then by produ ct category, and finally by subcategory. You can see that on 12/5/09, there were two different product categories sold: chairs and paper. For chairs, there were two different subcategories sold: metal and plastic. For each of these categories, the pivot table provides a breakdown of sales by custo mer. As such, pivot tables are very adept at summarizing data in innumerable ways. Additionally, users have the ability to arrange data items in almost any desired format. Looking Ahead In this chapter, we’ve examined a few ways in which reporting tools and spread- sheets can be used to display data in custom formats. In particular, the crosstab report adds an ability to summarize data in a way that is difficult to present strictly through SQL statements. Pivot tables in Excel utilize the basic concept of the crosstab report and extend it to provide additional flexibility and functionality for users. By being aware of reporting and user tools available to reformat data, SQL developers can focus their talents more productively on retrieving data and let the reporting tool or user handle more complex display issues. Now that you’ve completed the book, why not try out a few commands on your own? If you haven’t already done so, take a look at Appendices A, B, and C to get some tips on how to get started with Microsoft SQL Server, MySQL, or Oracle. These appendices provide instructions on how to install the free versions of these databases, and they also provide some basic information on how to use the software to execute SQL commands. Finally, I sincerely hope that this book has served as a useful guide into the world of SQL. At the start of the book, I mentioned that SQL involves both logic and Chapter 20 ■ Strategies for Displaying Data212 language. The language component is fairly obvious. In each chapter, I’ve stres- sed the keywords that are introduced and the meaning behind those words. But now that you’ve completed the book, I hope you can appreciate that the power of SQL is with the logic that it encompasses. It is pure logic that allows you take a bunch of values arranged in columns and rows and transform it into something approaching information. The challenge in using SQL is in determining how to apply logic to real-world data. This is where the theoretical and practical meet. In using functions, aggregation, joins, subqueries, views, and the like, you’ll grapple with the reality of raw data and learn how to manipulate it with a few twists of logic. But logic isn’t the end of the matter. The language of SQL plays an equally important role. I would say that the real beauty of SQL lies in the fact that the language is quite sparse. It’s neither cryptic nor verbose. Each keyword has a distinct purpose and specifies a particular bit of logic and nothing more. I wouldn’t go so far as to say that SQL has poetic qualities, but within the realm of computer languages, the language has a certain aesthetic appeal. Looking Ahead 213 This page intentionally left blank appendix A Getting Started with Microsoft SQL Server Overview The procedure to install the free version of Microsoft SQL Server is as follows. This procedure was tested on a PC with the Windows 7 operating system. Please note that the specific instructions may vary from what is shown here, depending on what is already installed on your PC. As these procedures may change over time, please consult www.courseptr.com/ downloads for any updates. There are two main steps involved: ■ Install SQL Server Express 2008 ■ Install SQL Server Management Studio Microsoft SQL Server Express 2008 allows you to create databases. The SQL Server Management Studio is a graphical interface that allows you to issue SQL commands to interact with the server and any databas es you create. Both downloads are available at www.microsoft.com/sqlserver. Installing SQL Server Express 2008 The steps for installing the Microsoft SQL Server database are as follows. 1. Go to www.microsoft.com/sqlserver. 215 . few twists of logic. But logic isn’t the end of the matter. The language of SQL plays an equally important role. I would say that the real beauty of SQL lies in the fact that the language is. a useful guide into the world of SQL. At the start of the book, I mentioned that SQL involves both logic and Chapter 20 ■ Strategies for Displaying Data212 language. The language component is. listed earlier, but with the addition of two new columns: Date and Subcategory. The Subcategory column is a further breakdown of the product category. In this pivot table, the date, product category,

Ngày đăng: 05/07/2014, 05:20

Xem thêm: The Language of SQL- P46 docx

TỪ KHÓA LIÊN QUAN

Mục lục

    Chapter 1 Relational Databases and SQL

    Microsoft SQL Server, Oracle, and MySQL

    Primary and Foreign Keys

    The Significance of SQL

    Chapter 2 Basic Data Retrieval

    Column Names with Embedded Spaces

    Chapter 3 Calculations and Aliases

    The Function of Functions

    Sorting in Ascending Order

    Sorting in Descending Order

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN