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
-
<%@page contentType="text/html" import="java.util.*" %> <!-- http://www.roseindia.net/jsp --> ...
-
Introduction: In this exercise, you will exercise the concept of pass by reference. Please not that primitive type parameters are passed ...
-
The SQL UPDATE general syntax looks like this: UPDATE Table1 SET Column1 = Value1, Column2 = Value2 WHERE Some_Column = Some_Value The SQL U...
-
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...
-
Now I will show you how to retrieve the data posted from a HTML file in a JSP page. Consider an html page that prompts the user to enter his...
-
Constructors A constructor is a special member function whose task is to initialize the objects of it's class. This is the first method ...
-
So far we’ve learnt how to select data from a database table and how to insert and update data into a database table. Now it’s time to learn...
-
Introduction: In this exercise, you will exercise the concept scope variable. Steps to follow: 1. Write ScopeOfVariable.java as shown in Cod...
-
The SQL INSERT INTO syntax has 2 main forms and the result of either of them is adding a new row into the database table. The first syntax f...
No comments:
Post a Comment