cumsumranking

The full problem statement is available to Pro members.

preloaded fixtures

import pandas as pd
import numpy as np

query_log = pd.DataFrame({
    "warehouse": ["ANALYST_WH", "ANALYST_WH", "ETL_WH", "ETL_WH", "BI_WH", "BI_WH", "ML_WH", "ML_WH"],
    "user_name": ["ada", "grace", "etl_bot", "etl_bot", "bi_service", "grace", "ml_bot", "ml_bot"],
    "day": ["2024-03-01", "2024-03-02", "2024-03-01", "2024-03-02", "2024-03-02", "2024-03-04", "2024-03-06", "2024-03-07"],
    "elapsed_sec": [12.5, 180.0, 900.0, 840.0, 22.0, 240.0, 3600.0, 1800.0],
    "bytes_scanned": [1200000, 52000000, 880000000, 790000000, 3400000, 61000000, 2400000000, 1200000000],
    "spilled": [0, 1, 1, 0, 0, 1, 1, 0],
})
query_log["day"] = pd.to_datetime(query_log["day"])

credits = pd.DataFrame({
    "warehouse": ["ANALYST_WH", "ANALYST_WH", "ETL_WH", "ETL_WH", "BI_WH", "ML_WH", "ML_WH"],
    "day": ["2024-03-01", "2024-03-02", "2024-03-01", "2024-03-02", "2024-03-02", "2024-03-06", "2024-03-07"],
    "credits": [1.5, 6.0, 40.0, 36.0, 2.5, 60.0, 30.0],
})
credits["day"] = pd.to_datetime(credits["day"])

Guest mode · solve history stays on this device; code isn’t saved. Sign in to save future work

Pro problem

“Credits with cumulative share”

This is one of the real interview questions in Pro. Try Pro free for 7 days to unlock it and everything below:

  • 293 interview-grade problems across SQL, Python & pandas
  • 104+ real-world SQL problems: SaaS retention, fintech ledgers, supply chain, recursive CTEs
  • 18 company interview packs (Amazon, Meta, Google, Uber and more)
  • AI "explain my mistake" tutor and mock interviews
  • Use QueryLab inside Claude, Cursor & other AI assistants

// built for real interview rounds

Practice the patterns 18 top companies test

329 problems · 36 free forever · 293 unlocked with Pro

Card required. Then $12/month. Cancel before your trial ends and you pay nothing.

or keep practicing free problems →

Secure checkout by Paddle · instant access · cancel anytime from your account