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

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:

主站蜘蛛池模板: 荣昌县| 黑龙江省| 涟源市| 定襄县| 高邮市| 荆州市| 崇义县| 长垣县| 乐平市| 栖霞市| 汝南县| 黔西县| 新龙县| 常德市| 星子县| 张家界市| 霍山县| 巴彦县| 米易县| 鄄城县| 二手房| 射洪县| 怀安县| 定安县| 唐山市| 赤壁市| 家居| 万载县| 西昌市| 噶尔县| 沾益县| 图木舒克市| 甘孜县| 特克斯县| 浦东新区| 弥渡县| 买车| 哈尔滨市| 双柏县| 台南县| 德令哈市|