0% found this document useful (0 votes)
7 views

SQL - Alias - 1keydata

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

SQL - Alias - 1keydata

Uploaded by

vickroid007
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

3/2/2016 SQL ­ Alias | 1Keydata

SQL Alias

SQL Data Warehousing CSS PHP HTML Database Normalization

SQL Tutorial Become a Cloud Computing Get Trained &


Certified by
Basic SQL Commands Expert Collabera TACT.
SQL SELECT
SQL DISTINCT
SQL WHERE SQL > SQL Commands > Alias
SQL AND OR
We next focus on the use of aliases. There are two types of aliases that are used most frequently: column alias and table a
SQL IN
SQL BETWEEN In short, column aliases exist to help organizing output. In the previous example, whenever we see total sales, it is listed a
SQL Wildcard While this is comprehensible, we can envision cases where the column heading can be complicated (especially if it involve
SQL LIKE arithmetic operations). Using a column alias would greatly make the output much more readable.
SQL ORDER BY
SQL GROUP BY The second type of alias is the table alias. This is accomplished by putting an alias directly after the table name in the
SQL HAVING convenient when you want to obtain information from two separate tables (the technical term is 'perform joins'). The adva
SQL ALIAS
table alias when doing joins is readily apparent when we talk about joins.
SQL AS
Before we get into joins, though, let's look at the syntax for both the column and table aliases:
SQL SELECT UNIQUE
SQL JOIN
SELECT "table_alias"."column_name1" "column_alias"
SQL INNER JOIN FROM "table_name" "table_alias";
SQL OUTER JOIN
SQL LEFT OUTER JOIN Briefly, both types of aliases are placed directly after the item they alias for, separate by a white space. We again use our t
SQL CROSS JOIN Store_Information,
SQL INSERT INTO
SQL INSERT INTO SELECT Table Store_Information
SQL UPDATE
Store_Name Sales Txn_Date
SQL DELETE FROM
Los Angeles 1500 Jan-05-1999
Advanced SQL
San Diego 250 Jan-07-1999
SQL UNION
Los Angeles 300 Jan-08-1999
SQL UNION ALL
Boston 700 Jan-08-1999
SQL Inline View
SQL INTERSECT
We use the same example as that in the SQL GROUP BY section, except that we have put in both the column alias and the
SQL MINUS
SQL LIMIT
SELECT A1.Store_Name Store, SUM(A1.Sales) "Total Sales"
SQL TOP FROM Store_Information A1
SQL Subquery GROUP BY A1.Store_Name;
SQL EXISTS
SQL CASE Result:
SQL DECODE
SQL AUTO INCREMENT Store Total Sales
SQL IDENTITY Los Angeles 1800
SEQUENCE & NEXTVAL San Diego 250
SQL Functions Boston 700
SQL Average
SQL COUNT Notice that difference in the result: the column titles are now different. That is the result of using the column alias.
SQL MAX somewhat cryptic "Sum(Sales)", we now have "Total Sales", which is much more understandable, as the column header. Th
SQL MIN using a table alias is not apparent in this example. However, they will become evident in the SQL Joins section.
SQL SUM
SQL ROUND
Next: SQL AS
String Functions
SQL CAST
SQL CONVERT Google Web Hosting
SQL CONCATENATE Build Your Online Presence With Google Sites. Free 30­Day Trial!
SQL SUBSTRING
SQL INSTR
SQL TRIM

http://www.1keydata.com/sql/sqlalias.html 1/2
3/2/2016 SQL ­ Alias | 1Keydata
SQL LENGTH
Copyright © 2016 1keydata.com All Rights Reserved Privacy Policy About Contact
SQL REPLACE
SQL TO_DATE

Date Functions

http://www.1keydata.com/sql/sqlalias.html 2/2

You might also like