PracHub
QuestionsPremiumCoachesLearningGuidesInterview Prep

Quick Overview

This question evaluates data manipulation and analytical SQL/Python competency, focusing on relational joins, aggregations, string filtering, ranking, and proportion calculations across multiple tables in a bookstore schema.

  • Medium
  • Meta
  • Data Manipulation (SQL/Python)
  • Data Scientist

Analyze Bookstore Data to Identify Top Payment Methods

Company: Meta

Role: Data Scientist

Category: Data Manipulation (SQL/Python)

Difficulty: Medium

Interview Round: Technical Screen

books +---------+------------+----------+-------+ | book_id | title | author_id| price | +---------+------------+----------+-------+ | 1 | SQL 101 | 10 | 29.99 | | 2 | Python | 11 | 39.99 | | 3 | ML Guide | 10 | 49.99 | +---------+------------+----------+-------+ ​ authors +-----------+-------+--------------------------+ | author_id | name | personal_url | +-----------+-------+--------------------------+ | 10 | Alice | example.com/alice | | 11 | Bob | example.com/bob_keyword | | 12 | Carol | example.com/carol | +-----------+-------+--------------------------+ ​ transactions +---------------+---------+-------------+----------+-----------+--------+ | transaction_id| book_id | customer_id | quantity | pay_method| amount | +---------------+---------+-------------+----------+-----------+--------+ | 1001 | 1 | 501 | 2 | Visa | 59.98 | | 1002 | 2 | 502 | 1 | PayPal | 39.99 | | 1003 | 3 | 503 | 1 | Visa | 49.99 | +---------------+---------+-------------+----------+-----------+--------+ ​ customers +-------------+-------+------------------------+ | customer_id | name | referred_by_customer_id| +-------------+-------+------------------------+ | 501 | Dan | NULL | | 502 | Eve | 501 | | 503 | Frank | 502 | +-------------+-------+------------------------+ ##### Scenario Online bookstore analytics for business insights using relational data. ##### Question Using the four-table bookstore schema, write a query to return the top 5 payment methods by total sales amount. 2) Calculate (a) the proportion of authors that have zero sales and (b) the proportion of authors whose personal_url contains a given keyword (e.g., 'keyword'). 3) Some customers are referred by other customers (customers.referred_by_customer_id). Find the 5 referrers whose referees purchased books with the highest average price; ignore customers who were not referred by anyone. ##### Hints Pay attention to LEFT/RIGHT joins, GROUP BY with COUNT(DISTINCT), windowing or ORDER BY + LIMIT, and handling NULL referrers.

Quick Answer: This question evaluates data manipulation and analytical SQL/Python competency, focusing on relational joins, aggregations, string filtering, ranking, and proportion calculations across multiple tables in a bookstore schema.

Last updated: Mar 29, 2026

Loading coding console...

PracHub

Master your tech interviews with 8,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

  • Compute ad impression conversion rates - Meta (medium)
  • Count unconnected posts and reactions - Meta (medium)
  • Count heavy callers in 7 days - Meta (medium)
  • Write SQL for call metrics - Meta (medium)
  • Write SQL for multi-account metrics - Meta (medium)