SQL Week-3
SQL Week-3
SQL Week-3
com
BX9T5ZHNQF
SQL( Week 3)
This file is meant for personal use by sunny1637@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
DSBA CURRICULUM DESIGN
CORE DOMAIN
FOUNDATIONS COURSES APPLICATIONS
sunny1637@gmail.com
Python for
BX9T5ZHNQF Data
Advanced Statistics Financial Risk
Science
Analytics
Data Mining
Statistical Methods
for Decision Making Marketing Retail
Predictive Modelling Analytics
Machine Learning
Data Visualization
SQL (Week-3/3)
Time Series
Forecasting
This file is meant for personal use by sunny1637@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
Table of Contents
• SQl Joins
•
sunny1637@gmail.com
BX9T5ZHNQF
Sub Query
Table Table
• LEFT JOIN − Returns all rows from the left A B
table, even if there are no matches in the
right table. (A ∩ B) U B
Table Table
A B
Table
• CARTESIAN JOIN (CROSS JOIN) − Returns the Table
B
A
Cartesian product of the sets of records
from the two or more joined tables.
This file is meant for personal use by sunny1637@gmail.com only. 6
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
SQL INNER JOIN
The INNER JOIN creates a new result table by combining column
values of two tables (table1 and table2) based upon the join-
predicate. The query compares each row of table1 with each row
of table2
sunny1637@gmail.com
to find all pairs of rows which satisfy the join-
BX9T5ZHNQF
predicate.
SYNTAX :
SELECT e.employee_id,
e.first_name, e.last_name,
d.department_id,
d.department_name employee_i first_name last_name departmen departmen
FROM employees e d t_id t_name
INNER JOIN departments d 101 Steven Cohen 10 IT
ON 102 Edwin Thomas 11 Marketing
e.department_id=d.department_id
;
This file is meant for personal use by sunny1637@gmail.com only. 9
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
SQL LEFT JOIN
The LEFT JOIN returns all the values from the left table, plus
matched values from the right table or NULL in case of no
matching join predicate.
SYNTAX :
sunny1637@gmail.com
BX9T5ZHNQF
SELECT e.employee_id,
e.first_name, e.last_name, employee first_name last_name departme departme
d.department_id, d.department_name _id nt_id nt_name
FROM employees e 101 Steven Cohen 10 IT
LEFT OUTER JOIN departments d
ON e.department_id = 102 Edwin Thomas 11 Marketing
d.department_id; 103 Harry Potter Null Null
100 Erik John Null Null
This file is meant for personal use by sunny1637@gmail.com only. 12
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
SQL RIGHT JOIN
• The RIGHT JOIN returns all the values from the right
table, plus matched values from the left table or NULL
in case of no matching join predicate.
sunny1637@gmail.com
SYNTAX :
BX9T5ZHNQF
SYNTAX :
sunny1637@gmail.com
BX9T5ZHNQF
SYNTAX:
sunny1637@gmail.com
BX9T5ZHNQF
• The CROSS JOIN produces a result set with the number of rows in
the first table multiplied by the number of rows in the second.
SYNTAX:
sunny1637@gmail.com
BX9T5ZHNQF
❑ General Format
• Get noticed by your management with your outstanding analysis backed by data science.
sunny1637@gmail.com
BX9T5ZHNQF
• Network with members from the data science vertical of your organization and seek
opportunities to contribute in small projects.
• Share your success stories with us and the world to position yourself as a subject matter expert
in data science.
This file is meant for personal use by sunny1637@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
sunny1637@gmail.com
BX9T5ZHNQF
ANY QUESTIONS
This file is meant for personal use by sunny1637@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.
sunny1637@gmail.com
BX9T5ZHNQF
HAPPY LEARNING
This file is meant for personal use by sunny1637@gmail.com only.
Sharing or publishing the contents in part or full is liable for legal action.
Proprietary content. ©Great Learning. All Rights Reserved. Unauthorized use or distribution prohibited.