Renaming the columns and calculations in the result set page 1 |
|||||||||||||||||||||||||||||
The column names listed in the SELECT clause can be changed. This can be done to increase readability because the column names are frequently abbreviated to simplify typing. The AS keyword being used for renaming can be neglected in accordance with the standard, since it is implicitly implied. For example, the following query renames the ram column as Mb (megabytes) and the hd column as Gb (gigabytes). This query will return the base memory amount and the hard drive storage on computers with a 24-speed CD-ROM:
Renaming is especially desired when using value-calculation expressions in SELECT clause. These expressions give the data which may not be directly derived from database tables. An expression including the column names of the table contained in the FROM clause is calculated for each row of the result set. For example, RAM amount in kilobytes can be obtained when writing: Now the following result will be obtained:
Sometimes, an explanation needs to be placed along with the corresponding value. To make this, add string expression as complementary column. For example, the query
Should the expression have no specified name, a default naming way will be used, dependable on DBMS used. For example, the names like expression1 and so on will be used in MS Access, while the column returned in MS SQL(Structured Query Language) is a database computer language designed for the retrieval and management of data in relational database management systems (RDBMS), database schema creation and modification, and database object access control management.SQL Server has no title at all. Suggested exercises: 32 |