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.00
Published
September 2020
Language
English (United States)
Last Update
2021-01-23
dita:mapPath
qtb1554762060450.ditamap
dita:ditavalPath
lze1555437562152.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);