0% found this document useful (0 votes)
4 views26 pages

Lesson 5 Programming

This document provides an overview of implementing column aliases in SQL, detailing their purpose and usage for making column headings more readable. It includes examples of SQL queries demonstrating how to create aliases for columns and tables, as well as assessment exercises for understanding the concepts. Additionally, it outlines criteria for evaluating the creation of tables and the selection of keys in a database project.

Uploaded by

ALDRIN LLAGAS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views26 pages

Lesson 5 Programming

This document provides an overview of implementing column aliases in SQL, detailing their purpose and usage for making column headings more readable. It includes examples of SQL queries demonstrating how to create aliases for columns and tables, as well as assessment exercises for understanding the concepts. Additionally, it outlines criteria for evaluating the creation of tables and the selection of keys in a database project.

Uploaded by

ALDRIN LLAGAS
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 26

Implementing Column Aliases LESSON 4

CHAPTER
RETRIEVING DATA USING THE 1
SQL SELECT STATEMENT
Lesson 1: Listing Capabilities of SQL SELECT Statements
Lesson 2: Generating Report of Data from the Output of a Basic
Select Statement
Lesson 3: Sorting and Restricting Data
Lesson 4: Using Arithmetic Expressions and NULL Values
Lesson 5: Implementing Column Aliases
Lesson 6: Describing Concatenation Operator, Literal Character
Strings, Alternative Quote Operator, and the Distinct Keyword
Implementing Column Aliases LESSON 4
TECHNICAL TERMS

• Column alias – used to make the name of the


column headings shorter and easier to read.
• Oracle alias – a name used as a substitute
for the name of columns, rows, or tables.
• Table alias – used to shorten the name of the
table to make it much easier to read.
Oracle aliases
are useful for a variety of reasons.
Users can alter or create temporary
names for columns or tables. Take a
look at this example. This shows how
to replace:
The first_name || last_name as FULLNAME. As a result,
FULLNAME will be displayed as the heading for the second
column when the result set is returned, or if the user wants to
use a two-word ALIAS, he or she can do this.

SELECT employee_id, first_name || last_name AS FULLNAME


FROM employees WHERE last_name = ‘Acona’
The example below shows how to replace the
first_name || last_name as FULLNAME. As a result, FULL
NAME will be displayed as the heading for the second
column when the result set is returned because of the
space inserted in between the alias.

SELECT employee_id, first_name || last_name AS “FULL NAME”


FROM employees
WHERE last_name = ‘Acona’;
DEMONSTRATION

SELECT LRN, FIRST_NAME || LAST_NAME AS "MyName"


FROM USERS
Where LAST_NAME = 'CRISPIN';
RUBRICKS:
Criteria Outstanding Adequate Not Adequate
(6 Pts.) (5 Pts.) (4 Pts.)
Table Creation Created all of the tables defined Created most of the tables Partially created some of the
in project requirements defined in project requirements tables defined in project
Named tables appropriately in Table name was a little unclear in requirements. Table name did not
regard to their data elements regard to its data elements correlate to its data elements

Keys and Entities Correctly choose all primary and Correctly choose most of the Incorrectly choose most of the
foreign keys respecting the primary and foreign keys primary and foreign Keys, and
naming convention respecting the naming convention somehow respected the naming
convention

Implementation Completely populated tables with Populated tables with majority of Populated tables with minimal
correct data elements reflecting data elements outlined in the data elements defined in project
the design design the design
SELF - Assessment

Needs
Skills Good Excellent
Improvement
• I know Column
Aliases.
• I can describe
Column Aliases.
• I can perform
Column Aliases.
Implementing Column Aliases LESSON 5
ASSESSMENT

A. Directions: Write the


syntax of the given
instructions.
1. As a result, MYNAME will display as
a substitute heading of column
LAST_NAME from table EMPLOYEE.
2. As a result, TELEPHONE will display
as a substitute heading of column
TEL_NO from table COMMUNICATION.
3. As a result, ADDRESS will display
as a substitute heading of column
HOMETOWN from table LOCATION.
4. As a result, LAPTOP will display as
a substitute heading of column
COMPUTER from table GADGETS.
5. As a result, JOBDESCRIPTION will
display as substitute heading for
column JOBS from table
DEPARTMENT.
6. As a result, AIRCON will display as
a substitute heading of column FAN
from table REFRESHMENT.
7. As a result, CHAIR will display as a
substitute heading of column BENCH
from table FURNITURE.
Pre-test

B. Direction: Identify the


following statements by
writing the correct answer
on the line.
___________1. This is used to alter the name
of a given table.
___________ 2. This is used as a substitute for
a name of columns, rows, or tables.
___________ 3. This is used to make the name
of the column headings shorter.
Implementing Column Aliases LESSON 5
A. Directions: Write the syntax of the given instructions.
1. SELECT LAST_NAME AS MYNAME from EMPLOYEE
2. SELECT TEL_NO AS TELEPHONE from COMMUNICATION
3. SELECT HOMETOWN AS ADDRESS from LOCATION
4. SELECT COMPUTER AS LAPTOP from GADGETS
5. SELECT JOBS AS JOBDESCRIPTION from DEPARTMENT
6. SELECT FAN AS AIRCON from REFRESHMENT
7. SELECT BENCH AS CHAIR from FURNITURE
B.
1. TABLE ALIAS
2. ORACLE ALIAS
3. COLUMN ALIAS
Implementing Column Aliases LESSON 5
Connect to the HR Account to generate a report of employees’ salaries
higher than ten thousand. Do these:
1. Open SQL Developer.
2. Connect to your Oracle database by typing your password.
3. Type the following code:
SELECT MIN_SALARY from JOBS
WHERE MIN_SALARY > 1000
4. Click the Run Statement button or press Ctrl+Enter.
The output should look like this:
Implementing Column Aliases LESSON 5

You might also like