A Guide to SQL (Available Titles Skills Assessment Manager (SAM) by Office 2010)
Author:Office 2010)
Language: eng
Format: epub
the number of the employee’s manager, who also is an employee. If you look at the row for
employee 206 (Joan Dykstra), you will see that employee 198 (Mona Canzler) is Joan’s
manager. By looking at the row for employee 198 (Mona Canzler), you see that her man-
ager is employee 108 (Martin Holden). In the row for employee 108 (Martin Holden), the
manager number is null, indicating that he has no manager.
149
Employee 108
has no manager
Employee 198
manages employee
206
FIGURE 5-14
Employee and manager data
Suppose you need to list the employee number, employee last name, and employee first
name along with the number, last name, and first name of each employee’s manager. Just
as in the previous self-join, you would list the EMPLOYEE table twice in the FROM clause
with aliases.
The command shown in Figure 5-15 uses the letter E as an alias for the employee and
the letter M as an alias for the manager. Thus E.EMPLOYEE_NUM is the employee’s num-
ber and M.EMPLOYEE_NUM is the number of the employee’s manager. In the SQL com-
mand, M.EMPLOYEE_NUM is renamed as MGR_NUM, M.LAST_NAME is renamed as
MGR_LAST, and M.FIRST_NAME is renamed as MGR_FIRST. The condition in the
WHERE clause ensures that E.MGR_EMPLOYEE_NUM (the number of the employee’s man-
ager) matches M.EMPLOYEE_NUM (the employee number on the manager’s row in the
table). Employee 108 is not included in the results because Martin Holden has no man-
ager (see Figure 5-14).
Multiple-Table Queries
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(8309)
Azure Data and AI Architect Handbook by Olivier Mertens & Breght Van Baelen(6789)
Building Statistical Models in Python by Huy Hoang Nguyen & Paul N Adams & Stuart J Miller(6765)
Serverless Machine Learning with Amazon Redshift ML by Debu Panda & Phil Bates & Bhanu Pittampally & Sumeet Joshi(6651)
Data Wrangling on AWS by Navnit Shukla | Sankar M | Sam Palani(6438)
Driving Data Quality with Data Contracts by Andrew Jones(6377)
Machine Learning Model Serving Patterns and Best Practices by Md Johirul Islam(6138)
Learning SQL by Alan Beaulieu(6004)
Weapons of Math Destruction by Cathy O'Neil(5795)
Big Data Analysis with Python by Ivan Marin(5388)
Data Engineering with dbt by Roberto Zagni(4393)
Solidity Programming Essentials by Ritesh Modi(4043)
Time Series Analysis with Python Cookbook by Tarek A. Atwan(3899)
Pandas Cookbook by Theodore Petrou(3601)
Blockchain Basics by Daniel Drescher(3305)
Hands-On Machine Learning for Algorithmic Trading by Stefan Jansen(2914)
Feature Store for Machine Learning by Jayanth Kumar M J(2819)
Learn T-SQL Querying by Pam Lahoud & Pedro Lopes(2802)
Mastering Python for Finance by Unknown(2748)
