Amazon Athena is a serverless query service that simplifies analyzing big data using standard SQL. Chapter 4, Advanced Query Techniques, delves into essential topics like complex SQL queries, joins, aggregations, functions, and effective table management. These Amazon Athena MCQ questions and answers are ideal for honing your expertise and preparing for assessments.
Complex SQL Queries
Which of the following is a valid example of a subquery? a) SELECT * FROM table WHERE column > 100; b) SELECT * FROM (SELECT column FROM table); c) SELECT column FROM table GROUP BY column; d) SELECT * FROM table ORDER BY column;
What keyword is used in SQL to filter groups of data? a) FILTER b) HAVING c) WHERE d) GROUP
How can you limit the number of rows returned by a query? a) LIMIT b) FETCH c) TOP d) ALL
Which operator is used to compare a column value against a range of values? a) LIKE b) IN c) BETWEEN d) ALL
A query with a UNION operator does what? a) Combines results from multiple SELECT statements without duplicates b) Combines rows from different tables c) Filters rows using a condition d) Merges columns in a table
Joins, Aggregations, and Functions
Which type of JOIN returns all rows from both tables, even when there is no match? a) INNER JOIN b) OUTER JOIN c) CROSS JOIN d) LEFT JOIN
What is the primary purpose of the GROUP BY clause? a) Aggregate data b) Sort rows c) Filter rows d) Join tables
Which function calculates the average value of a column? a) AVG() b) SUM() c) COUNT() d) MIN()
What does the COUNT(*) function return? a) The sum of all values in a column b) The number of rows in a table c) The maximum value in a column d) The distinct count of a column
What does a LEFT JOIN do? a) Selects matching rows from both tables b) Selects all rows from the left table and matching rows from the right table c) Combines rows without matching conditions d) Only selects matching rows from the right table
Views and Table Management
What is a view in SQL? a) A copy of a table stored in memory b) A virtual table based on a query c) A permanent table d) A temporary table
How do you update an existing view? a) ALTER VIEW b) MODIFY VIEW c) REFRESH VIEW d) UPDATE VIEW
What is the benefit of partitioning in Athena tables? a) Speeds up query performance by filtering data b) Merges duplicate rows c) Creates an exact copy of the table d) Combines columns
Which SQL statement is used to create a table? a) CREATE TABLE b) MAKE TABLE c) BUILD TABLE d) FORM TABLE
How do you drop a view in SQL? a) REMOVE VIEW b) DELETE VIEW c) DROP VIEW d) TRUNCATE VIEW
What does the MSCK REPAIR TABLE command do in Athena? a) Updates an existing table schema b) Recalculates the statistics for a table c) Adds metadata for new partitions d) Deletes unused partitions
What is the default storage format for Athena tables? a) CSV b) ORC c) Parquet d) JSON
Which command is used to rename a table in Athena? a) ALTER TABLE b) RENAME TABLE c) MODIFY TABLE d) CHANGE TABLE
What happens if you query an unpartitioned table? a) Results are faster b) Queries scan the entire dataset c) Query fails d) Only first partition is scanned
Which of the following statements creates a partitioned table in Athena? a) CREATE TABLE table_name PARTITIONED BY (column_name); b) CREATE TABLE table_name WITH PARTITION(column_name); c) CREATE PARTITIONED TABLE table_name; d) CREATE TABLE_PARTITION table_name(column_name);
Answers Table
Qno
Answer
1
b) SELECT * FROM (SELECT column FROM table);
2
b) HAVING
3
a) LIMIT
4
c) BETWEEN
5
a) Combines results from multiple SELECT statements without duplicates
6
b) OUTER JOIN
7
a) Aggregate data
8
a) AVG()
9
b) The number of rows in a table
10
b) Selects all rows from the left table and matching rows from the right table
11
b) A virtual table based on a query
12
a) ALTER VIEW
13
a) Speeds up query performance by filtering data
14
a) CREATE TABLE
15
c) DROP VIEW
16
c) Adds metadata for new partitions
17
b) ORC
18
a) ALTER TABLE
19
b) Queries scan the entire dataset
20
a) CREATE TABLE table_name PARTITIONED BY (column_name);