AWS Certified Data Engineer Associate DEA-C01 Practice Question
An Amazon Athena table named clickstream contains columns session_id string, page string, event_time timestamp, and load_time_ms int. A data engineer must return the five pages with the highest average load_time_ms recorded in the last 7 days, but only for pages that have at least 100 distinct sessions. Which SQL query satisfies the requirement?
SELECT page,
AVG(load_time_ms) AS avg_load
FROM clickstream
GROUP BY page
HAVING COUNT(DISTINCT session_id) >= 100
AND event_time >= current_timestamp - INTERVAL '7' day
ORDER BY avg_load DESC
LIMIT 5;
SELECT page,
AVG(load_time_ms) AS avg_load
FROM clickstream
WHERE event_time >= current_timestamp - INTERVAL '7' day
GROUP BY page
HAVING COUNT(DISTINCT session_id) >= 100
ORDER BY COUNT(DISTINCT session_id) DESC
LIMIT 5;
SELECT page,
AVG(load_time_ms) AS avg_load
FROM clickstream
WHERE event_time >= current_timestamp - INTERVAL '7' day
AND COUNT(DISTINCT session_id) >= 100
GROUP BY page
ORDER BY avg_load DESC
LIMIT 5;
SELECT page,
AVG(load_time_ms) AS avg_load
FROM clickstream
WHERE event_time >= current_timestamp - INTERVAL '7' day
GROUP BY page
HAVING COUNT(DISTINCT session_id) >= 100
ORDER BY avg_load DESC
LIMIT 5;
The correct query uses multiple qualifiers in the appropriate order: WHERE filters rows that fall within the last 7 days, GROUP BY aggregates by page, HAVING keeps only pages whose aggregated count of distinct session_id values meets the threshold, ORDER BY sorts on the derived average, and LIMIT returns the top five results. Aggregated conditions cannot appear in a WHERE clause, and non-grouped columns such as event_time cannot appear in HAVING without aggregation. Ordering by the session count would not satisfy the requirement to sort by the highest average load_time_ms.
Ask Bash
Bash is our AI bot, trained to help you pass your exam. AI Generated Content may display inaccurate information, always double-check anything important.
Why is HAVING used instead of WHERE for aggregated conditions?
Open an interactive chat with Bash
What happens if ORDER BY uses COUNT instead of AVG in this query?
Open an interactive chat with Bash
Why is INTERVAL '7' day used with current_timestamp?
Open an interactive chat with Bash
AWS Certified Data Engineer Associate DEA-C01
Data Operations and Support
Your Score:
Report Issue
Bash, the Crucial Exams Chat Bot
AI Bot
Loading...
Loading...
Loading...
Pass with Confidence.
IT & Cybersecurity Package
You have hit the limits of our free tier, become a Premium Member today for unlimited access.
Military, Healthcare worker, Gov. employee or Teacher? See if you qualify for a Community Discount.
Monthly
$19.99
$19.99/mo
Billed monthly, Cancel any time.
3 Month Pass
$44.99
$14.99/mo
One time purchase of $44.99, Does not auto-renew.
MOST POPULAR
Annual Pass
$119.99
$9.99/mo
One time purchase of $119.99, Does not auto-renew.
BEST DEAL
Lifetime Pass
$189.99
One time purchase, Good for life.
What You Get
All IT & Cybersecurity Package plans include the following perks and exams .