Product Profit Summary
Updated
Problem statement
A shop keeps two tables. The products table lists each product with its product_name and the unit_cost the shop pays for one unit. The sales table has one row per sale: the product_id, the quantity of units sold and the unit_price each unit was sold for. The same product can sell at different prices.
Return one row for every product in products, with these columns:
product_idandproduct_nameunits_sold: the total quantity sold.revenue: the sum ofquantity * unit_priceover its sales.profit: revenue minus cost, where the cost of a sale isquantity * unit_cost. It is negative when the product sold below cost.
A product with no sales gets 0 in all three number columns. Return the rows in any order. A decimal answer is accepted when it is within 0.0001 of the exact value.
Table schema
Use the same input data with any supported language. Open the Schema tab in the editor to see the generated SQL setup or Pandas DataFrames.
products
One row per product.
| Column | Type | Nullable | Description |
|---|---|---|---|
| product_idPK | Integer | No | Unique product ID. |
| product_name | Text | No | Product name. |
| unit_cost | Decimal | No | What one unit costs the shop. |
sales
One row per sale.
| Column | Type | Nullable | Description |
|---|---|---|---|
| sale_idPK | Integer | No | Unique sale ID. |
| product_id | Integer | No | Product sold. |
| quantity | Integer | No | Units sold. |
| unit_price | Decimal | No | Price of each unit in this sale. |
Expected result
Your query or function must return these columns.
| Column | Type | Nullable | Description |
|---|---|---|---|
| product_id | Integer | No | — |
| product_name | Text | No | — |
| units_sold | Integer | No | — |
| revenue | Decimal | No | — |
| profit | Decimal | No | — |
Row order: any order is accepted. Numeric tolerance: 0.0001.
Constraints
productshas between1and100rows, andproduct_idvalues are unique.product_namehas 1 to 30 characters: English letters, digits and spaces. Two products may share a name.saleshas between1and1000rows,sale_idvalues are unique, and every sale'sproduct_idappears inproducts.1 <= quantity <= 100000 < unit_cost, unit_price <= 1000, with at most 4 digits after the decimal point.
More Jane Street interview questions
- Cheating CodemakerOA · Seen Mar 2026
- Bond Haircut by Ratings and MaturityOA · Seen Aug 2024
- Currency Haircut with FX ForwardsOA · Seen Aug 2024
- Transform StringOA · Seen Jul 2024
- Price Deviation AlertsOA · Seen Nov 2023
- Trade Blotter Summary by TickerOA · Seen Jun 2021
- Biggest Daily Move and Longest Rising StreakOA · ONSITE INTERVIEW · Seen Apr 2021
- Transaction Fees by InstrumentOA · Seen Mar 2018
- Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
- Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
Similar questions at other companies
- Students Scoring Above AverageCapstone Investment Advisors · OA
- Bond Interest Summary Above 3%Wells Fargo · OAWells Fargo interview questions
- Employee Promotion OpportunitiesIntuit · OAIntuit interview questions
- Students and Their SubjectsBirla Pivot · OA
- Companies with Average Salary Above 40000AT&T · OAAT&T interview questions
- Build Taxi Driver Performance FeaturesBoston Consulting Group · OABoston Consulting Group interview questions
- Weekend Appointments for Consular Services ReschedulingMcKinsey & Company · OAMcKinsey & Company interview questions
- Companies Above a Salary ThresholdVerisk · OA
- Customer Resource Usage AnalysisIBM · OAIBM interview questions
- Customers Who Never OrderedAccenture · OAAccenture interview questions