SQL aliases can be used with database tables and with database table columns, depending on task you are performing.
SQL column aliases are used to make the output of your SQL queries easy to read and more meaningful:
SELECT Employee, SUM(Hours) As SumHoursPerEmployee
FROM EmployeeHours
GROUP BY Employee
In the example above we created SQL alias SumHoursPerEmployee and the result of this SQL query will be the following:
Employee SumHoursPerEmployee
John Smith 25
Allan Babel 24
Tina Crown 27
Consider the following SQL statement, showing how to use SQL table aliases:
SELECT Emp.Employee
FROM EmployeeHours AS Emp
Here is the result of the SQL expression above:
Employee
John Smith
Allan Babel
Tina Crown
The SQL table aliases are very useful when you select data from multiple tables.
Popular Posts
-
If you want to do something more complex than insert a simple expression, JSP scriptlets let you insert arbitrary code into the servlet meth...
-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <TITLE>Using JavaServer Pages...
-
The SQL AVG aggregate function selects the average value for certain table column. Have a look at the SQL AVG syntax: SELECT AVG(Column1) FR...
-
The SQL SELECT INTO statement is used to select data from a SQL database table and to insert it to a different table at the same time. The g...
-
Lab exercises and homeworks: * Things to check before you start the lab * Chapter 3 (Class #1, Jan. 16th homework) o Exerc...
-
Polymorphism Polymorphism is one of the crucial features of OOP. It means "one name, multiple forms". It is also called as Overlo...
-
Introduction: In this exercise, you will exercise the concept of pass by reference. Please not that primitive type parameters are passed ...
-
SQL Replication term describes a group of technologies allowing information distribution and mirroring between different databases. SQL repl...
-
Input/Output with files C++ provides the following classes to perform output and input of characters to/from files: * ofstream: Stream c...
-
Structures Structures can be defined as a tool for handling a group of logically related data items. They are user-defined and provide a met...
No comments:
Post a Comment