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

  • Learn T-SQL Querying
  • Pedro Lopes Pam Lahoud
  • 224字
  • 2021-06-24 14:38:08

Building blocks of a T-SQL statement

When writing a T-SQL statement, the following three actions are required:

  1. Express the intended operation, such as reading or changing data
  2. Provide a target or source list of affected tables
  3. Provide a condition that filters the affected records

The intended operation is determined by the presence of the following clauses:

  • The SELECT clause lists columns or expressions that will be displayed in the result set
  • The DELETE, INSERT, or UPDATE clauses state the target table or view for these logical operations

As for the affected tables and filters, they are determined by the following clauses:

  • The FROM clause lists the source tables, views and/or sub-queries that contain the data to be queried
  • The WHERE clause states one or more conditions that will serve to filter the result set to the desired rows

The preceding clauses determine which data will be manipulated. The formatting of the results can be further modified by adding any of the following parts:

  • The ORDER BY clause defines the order in which the rows will be returned
  • The GROUP BY clause aggregates rows together based on the criteria provided (typically combined with aggregate functions in the SELECT clause)
  • The HAVING clause applies a predicate to the results (different than the WHERE clause, which applies a predicate to the source rows)
主站蜘蛛池模板: 奉化市| 呈贡县| 太原市| 珠海市| 休宁县| 衡水市| 保亭| 新河县| 汕头市| 乌鲁木齐市| 环江| 团风县| 柏乡县| 阳高县| 台前县| 石林| 宁海县| 湖北省| 青海省| 江源县| 通河县| 永丰县| 夏津县| 天柱县| 武胜县| 迁安市| 肃宁县| 玉树县| 合川市| 中阳县| 沁源县| 陇西县| 万宁市| 申扎县| 九龙县| 宜良县| 望都县| 雷波县| 敦化市| 庆云县| 临泉县|