PracHub
QuestionsPremiumLearningGuidesCheatsheetNEWCoaches

Quick Overview

This question evaluates competency in data manipulation and aggregation using SQL or Python, focusing on grouping, conditional aggregation, and handling related product and purchase records. It is commonly asked for Data Manipulation (SQL/Python) roles to assess practical application of filtering and aggregation logic for per-category summaries rather than purely conceptual understanding.

  • medium
  • Capital One
  • Data Manipulation (SQL/Python)
  • Data Analyst

Find Lowest Prices for Highly Rated Categories

Company: Capital One

Role: Data Analyst

Category: Data Manipulation (SQL/Python)

Difficulty: medium

Interview Round: Take-home Project

You are given two tables containing product catalog information and purchase records. ### Tables `products` | Column | Type | Description | |---|---:|---| | `id` | INT | Primary key for the product. | | `category` | VARCHAR | Product category, such as `apple`, `orange`, or `banana`. | | `product_name` | VARCHAR | Name of the product. | `purchases` | Column | Type | Description | |---|---:|---| | `id` | INT | Primary key for the purchase record. | | `product_id` | INT | Foreign key referencing `products.id`. | | `price` | DECIMAL(10,2) | Purchase price of the product. | | `stars` | DECIMAL(2,1) | Customer rating for the purchase. | ### Task For each product category in `products`, return the lowest purchase price in that category **only if the category has at least one purchase with `stars > 4`**. If a category does not have any purchase with `stars > 4`, return `0` as the price for that category. ### Assumptions - Include every category that appears in `products`. - A category may contain multiple products and each product may have multiple purchase records. - If a category has at least one purchase with `stars > 4`, compute the minimum `price` across purchases in that category. - If a category has no purchases, return `0`. - There is no time filter for this question, so timezone handling is not applicable. ### Required Output Return one row per category. | Column | Type | Description | |---|---:|---| | `category` | VARCHAR | Product category. | | `price` | DECIMAL(10,2) or INT | Lowest price for qualifying categories; otherwise `0`. | Example output format: | category | price | |---|---:| | apple | 0 |

Quick Answer: This question evaluates competency in data manipulation and aggregation using SQL or Python, focusing on grouping, conditional aggregation, and handling related product and purchase records. It is commonly asked for Data Manipulation (SQL/Python) roles to assess practical application of filtering and aggregation logic for per-category summaries rather than purely conceptual understanding.

Last updated: May 7, 2026

Loading coding console...

PracHub

Master your tech interviews with 7,500+ real questions from top companies.

Product

  • Questions
  • Learning Tracks
  • Interview Guides
  • Resources
  • Premium
  • For Universities
  • Student Access

Browse

  • By Company
  • By Role
  • By Category
  • Topic Hubs
  • SQL Questions
  • Compare Platforms
  • Discord Community

Support

  • support@prachub.com
  • (916) 541-4762

Legal

  • Privacy Policy
  • Terms of Service
  • About Us

© 2026 PracHub. All rights reserved.

Related Coding Questions

  • Clean and Merge Housing Data - Capital One (easy)
  • Write SQL to compute campaign net revenue - Capital One (Medium)
  • Merge CSVs and build revenue pivot with pandas - Capital One (Medium)
  • Find top category per region in Aug 2025 - Capital One (Medium)
  • Reconcile ledgers with SQL/Python and late events - Capital One (Medium)