Example: Simple Subquery Using an AVG Aggregate Expression - Analytics Database - Teradata Vantage

SQL Data Manipulation Language

Deployment
VantageCloud
VantageCore
Edition
Enterprise
IntelliFlex
VMware
Product
Analytics Database
Teradata Vantage
Release Number
17.20
Published
June 2022
ft:locale
en-US
ft:lastEdition
2025-04-02
dita:mapPath
pon1628111750298.ditamap
dita:ditavalPath
qkf1628213546010.ditaval
dita:id
esx1472246586715
lifecycle
latest
Product Category
Teradata Vantageā„¢

The following SELECT statement finds every employee in the employee table with a salary that is greater than the average salary of all employees in the table.

     SELECT name, dept_no, jobtitle, salary
     FROM employee
     WHERE salary > (SELECT AVG(salary)
                     FROM employee)
     ORDER BY name;

The statement returns this results table.

name

----

dept_no

-------

jobtitle

--------

salary

------

Aguilar J 600 Manager 45,000.00
Carter J 500 Engineer 44,000.00
Omura H 500 Programmer 40,000.00
Phan A 300 Vice President 55,000.00
Regan R 600 Purchaser 44,000.00
Russell S 300 President 65,000.00
Smith T 500 Engineer 42,000.00
Smith T 700 Manager 45,000.00
Watson L 500 Vice President 56,000.00