Subquery Examples | SQL SELECT Statements | Teradata Vantage - Example: Simple Subquery Using the IN Logical Predicate - Advanced SQL Engine - Teradata Database

SQL Data Manipulation Language

Product
Advanced SQL Engine
Teradata Database
Release Number
17.10
Published
July 2021
ft:locale
en-US
ft:lastEdition
2021-07-27
dita:mapPath
vjt1596846980081.ditamap
dita:ditavalPath
vjt1596846980081.ditaval
dita:id
B035-1146
lifecycle
previous
Product Category
Teradata Vantageā„¢

This example selects the names and department locations of those employees who report to manager Aguilar (whose employee number is 10007).

     SELECT name, loc      FROM employee, department      WHERE employee.dept_no = department.dept_no      AND   employee.dept_no IN (SELECT dept_no                                 FROM department                                 WHERE mgr_no = 10007);