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

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:

主站蜘蛛池模板: 红桥区| 长垣县| 兴业县| 万安县| 万荣县| 蒙城县| 建平县| 枣阳市| 广德县| 萨迦县| 建阳市| 太原市| 望奎县| 延安市| 景谷| 开江县| 宁南县| 双流县| 聊城市| 内黄县| 塘沽区| 大关县| 澎湖县| 宝鸡市| 屯留县| 梅州市| 祁门县| 武陟县| 兴宁市| 缙云县| 乌苏市| 额敏县| 汶川县| 义乌市| 广宗县| 仪陇县| 乐陵市| 鹿邑县| 马边| 夏津县| 加查县|