SQL
Lab
Google Google Drive Interview Question 09

Storage
Usage

Find users who exceeded 15GB storage.

Table Schema

Inspect
Table

interactive
ColumnType
file_idinteger
user_idinteger
size_mbinteger

Sample Data

Input
Output

Sample Input: files
file_iduser_idsize_mb
11015000
21016000
31017000
41023000
51022000
610316000
71042000
Expected Output
user_id
101
103

SQL Editor

Run
Query

postgresql
Waiting for query

user_id
101
103

Hints

Unlock
Clues

Hint 01: 15GB equals 15360MB if 1GB is 1024MB.
Hint 02: Sum size_mb by user.
Hint 03: Filter users above the threshold.

Solution

Locked
Answer

Solution is locked until you decide to reveal it. Try the editor first, then open this when you want the reference answer.

SELECT
  user_id
FROM files
GROUP BY user_id
HAVING SUM(size_mb) > 15360;

Explanation

Step By
Step

01

Group files by user.

02

Sum storage in MB.

03

Keep users whose total exceeds 15360 MB.

Related Questions

Keep
Solving