zoukankan      html  css  js  c++  java
  • SQL Alias

    There are two types of aliases that are used most frequently in SQL command: which is column alias and table alias.

    Why ALIAS? There is some reasons alias to be use when querying a SQL command.

    - alias in a long query can make your query easier to read and understand
    - alias table is use when using a same table in one query
    - alias column is to identify the column naming when used together with aggregate functions, then the column can be understand easily

    Syntax for Column Name Alias is :

    SELECT [COLUMN NAME] AS COLUMN_ALIAS FROM [TABLE NAME]

    Syntax for Table Name Alias is :

    SELECT [COLUMN NAME] FROM [TABLE NAME] AS TABLE_ALIAS

    Example will using this table : Table GameScores

    PlayerName Department Scores
    Jason IT 3000
    Irene IT 1500
    Jane Marketing 1000
    David Marketing 2500
    Paul HR 2000
    James HR 2000


    EXAMPLE for Column Name Alias :

    let's say we want to refer to a simple example that just change the table name as DepartmentGameScores

    SQL statement :

    SELECT * FROM GameScores AS DepartmentGameScores

    Result:

    Table DepartmentGameScores

    PlayerName Department Scores
    Jason IT 3000
    Irene IT 1500
    Jane Marketing 1000
    David Marketing 2500
    Paul HR 2000
    James HR 2000


    EXAMPLE for Table Name Alias :

    let's say we want to refer to a simple example which is return sum of the scores in the table. this example is taken from SQL SUM

    SQL statement :

    SELECT SUM(Scores) AS Total_score
    FROM
    GameScores

    Result:

    Total_score
    12000
  • 相关阅读:
    C#秘密武器之表达式树
    C#秘密武器之特性
    [转]拷贝构造函数详解
    [转]STL 容器一些底层机制
    C++ Qt多线程 TcpSocket服务器实例
    QByteArray储存二进制数据(包括结构体,自定义QT对象)
    [转]浅谈 C++ 中的 new/delete 和 new[]/delete[]
    [转]QList内存释放
    Subscribe的第四个参数用法
    ROS多线程订阅消息
  • 原文地址:https://www.cnblogs.com/zhoug2020/p/3328305.html
Copyright © 2011-2022 走看看