- Making your query results easier to read
- Can make your query easier to read especially when you have multiple joins
- Giving meaningful names to columns
- Giving names to aggregated columns
- AliasName = ColumnName
- ColumnName AS AliasName
Here are some examples of how to use aliases in your queries:
First using an alias to give a column another name:
This query will give you the following results, notice the salesorderid has the label OrderNo and the TotalDue column has the label OrderValue:
The following query uses aliases for the table names; this makes it easy to see which table each column is coming from as well as saving on typing:
Finally here's a simple example of using an alias to name an aggregated column otherwise it wouldn't have a column heading:
No comments:
Post a Comment