Home     SQL Basic     Contact Us     Site Map    

SQL BASIC

SQL SELECT

SQL WHERE

SQL DISTINCT

SQL AND

SQL OR

SQL NOT

SQL ORDER BY

SQL IN

SQL BETWEEN

SQL LIKE

SQL ALIAS

SQL AGGREGATE

>SQL COUNT

>SQL SUM

>SQL MAX

>SQL MIN

>SQL AVG

SQL GROUP BY

SQL HAVING

SQL INSERT

SQL UPDATE

SQL DELETE

SQL SELECT INTO

SQL CREATE DATABASE

SQL CREATE TABLE

SQL DROP TABLE

SQL DROP DATABASE

SQL CREATE INDEX

SQL PRIMARY KEY

SQL FOREIGN KEY

SQL ALTER TABLE

SQL TRUNCATE TABLE

SQL JOIN

SQL INNER JOIN

SQL OUTER JOIN

SQL CROSS JOIN

SQL UNION

SQL UNION ALL

SQL INTERSECT



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

PlayerNameDepartmentScores
JasonIT3000
IreneIT1500
JaneMarketing1000
DavidMarketing2500
PaulHR2000
JamesHR2000


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

PlayerNameDepartmentScores
JasonIT3000
IreneIT1500
JaneMarketing1000
DavidMarketing2500
PaulHR2000
JamesHR2000


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