Microsoft-style Company ChallengeBeginnerVerified answerSQLite live

Usage Records Count

How many product usage sessions have been logged in total?

  • Aggregation

Challenge brief

Understand the request

Data Engineering is validating the telemetry pipeline and needs the total row count in usage_logs as a data quality checkpoint.

Return the total row count of the usage_logs table as total_logs.

Return

  • total_logs

Constraints

  • Return one row containing the complete usage-session count

Data you will use

Review the relevant tables before deciding how to join, filter, or aggregate them.

usage_logs

  • log_idINTEGER
  • user_idINTEGER
  • product_idINTEGER
  • usage_dateDATE
  • usage_minutesINTEGER

Hints, when you need them

Open one clue at a time so you still do the reasoning.

Hint 1

Each row in usage_logs represents one usage session. Count all rows — no filter or GROUP BY.

Hint 2

SELECT COUNT(*) AS total_logs FROM usage_logs.

Hint 3

Build question 6 from the required result grain: choose the driving table, add only the joins and filters needed for that grain, then apply aggregation and deterministic ordering.

Verified SQL answer

Attempt the problem first, then compare structure and reasoning—not just syntax.

Reveal solution and explanation
SELECT COUNT(*) AS total_logs FROM usage_logs;

Why this works

There are 16 usage session records. Some users appear multiple times: user 1 (2 sessions), user 7 (2), user 8 (2), user 12 (2). The remaining 8 users each have 1 session.

Success check

1 row — total_logs: 16

Expected result

Use this output to verify values, aliases, ordering, and row count.

total_logs
16

Learn the concepts behind this answer

Strengthen your understanding with these targeted learning topics:

Continue practicing

SQL Interview Practice

Return to the complete interview preparation experience.