Teradata Teradata SQL 1 — Questions and Answers
Question 1: Which Teradata SQL clause is used to eliminate duplicate rows from a result set?
- DISTINCT (Correct answer)
- UNIQUE
- NODUPLICATE
- FILTER
Correct answer: DISTINCT
The DISTINCT keyword in a SELECT statement removes duplicate rows from the query result set.
Question 2: What does the QUALIFY clause do in Teradata SQL?
- Filters rows based on window function results (Correct answer)
- Defines table partitioning
- Applies row-level security
- Sets the query band
Correct answer: Filters rows based on window function results
QUALIFY filters rows based on the result of an ordered analytical (window) function, similar to HAVING for aggregates.
Question 3: Which Teradata join type returns all rows from both tables, including unmatched rows from each side?
- FULL OUTER JOIN (Correct answer)
- LEFT OUTER JOIN
- CROSS JOIN
- INNER JOIN
Correct answer: FULL OUTER JOIN
A FULL OUTER JOIN returns all rows from both tables, filling NULLs where there is no match on either side.
Question 4: In Teradata, what is the purpose of the SAMPLE clause?
- Returns a random subset of rows (Correct answer)
- Creates a table sample
- Copies statistics to another table
- Sets the row limit for exports
Correct answer: Returns a random subset of rows
The SAMPLE clause retrieves a random sample of rows from a table, useful for testing or statistical analysis.
Question 5: Which aggregate function in Teradata returns the middle value of an ordered dataset?
- MEDIAN (Correct answer)
- AVG
- MIDDLE
- CENTER
Correct answer: MEDIAN
The MEDIAN function returns the middle value of a numeric column when the values are sorted in ascending order.
Question 6: What does the CAST function do in Teradata SQL?
- Converts a value from one data type to another (Correct answer)
- Formats a string for display
- Joins two columns
- Creates a derived column alias
Correct answer: Converts a value from one data type to another
CAST converts an expression or column value from one data type to another, such as converting VARCHAR to INTEGER.
Which Teradata SQL clause is used to eliminate duplicate rows from a result set?