官术网_书友最值得收藏!

SELECT

The SELECT clause defines the columns and expressions that will be returned in the results and is the only element that is required to form a valid T-SQL data retrieval statement. Elements in the SELECT statement can be as simple as a single constant value, or as complex as a full T-SQL sub-query, but generally it is a comma-separated list of columns from tables and views in a database.

The following query will return a single row with a single column:

 SELECT 1;

In the following screenshot we can see the result:

The SELECT clause can also be used to format the results by providing column aliases or using expressions to modify the data. Aliases are created with the optional keyword AS, followed by the intended column name to be displayed in the result set:

SELECT Name AS ProductName, LEFT(ProductNumber, 2) AS ProductCode, ISNULL(color, 'No Color') AS Color [...]

Note that, in the results, any row that has a value for Color will display that value, whereas any row that has a null color will display No Color instead:

主站蜘蛛池模板: 郧西县| 上饶县| 虞城县| 兴宁市| 囊谦县| 宝坻区| 南丰县| 梅河口市| 贞丰县| 绥滨县| 志丹县| 定兴县| 冀州市| 孝昌县| 绥滨县| 濮阳县| 吉木萨尔县| 博湖县| 嘉善县| 新津县| 扶沟县| 江川县| 多伦县| 西峡县| 白玉县| 时尚| 沁水县| 安远县| 疏勒县| 长寿区| 舟山市| 兴海县| 株洲县| 民县| 清流县| 开平市| 梅州市| 额尔古纳市| 句容市| 黑山县| 山西省|