Prepin
Log in

Online shopping (5 out of 5)

Approach / Explanation

Providing a detailed explanation is challenging without knowing the exact question regarding e-commerce in SQL. However, for the purpose of this discussion, let's assume the question is: "How can SQL be utilized to analyze e-commerce transaction data?" This question seeks to understand how SQL can be employed to interpret, analyze, and extract insights from a dataset of e-commerce transactions. The interviewer is particularly interested in your ability to demonstrate: Your understanding of SQL syntax, commands, and functions. Your analytical capabilities to derive valuable insights from raw data. Your familiarity with e-commerce datasets, including knowledge of variables such as CART_ID, PRODUCT_ID, USER_ID, PURCHASE_DATE, and others.

Suggested Answer

-- Retrieve the top 10 products based on purchase frequency. SELECT PRODUCT_ID , COUNT ( * ) AS NUMBER_OF_PURCHASES FROM TRANSACTION_DATA GROUP BY PRODUCT_ID ORDER BY NUMBER_OF_PURCHASES DESC LIMIT 10 ; This SQL query retrieves the 10 most frequently purchased products, determined by the total number of purchases. It utilizes the COUNT(*) function to calculate the purchase count for each distinct PRODUCT_ID and employs the ORDER BY clause to arrange the results in descending order. The LIMIT 10 clause restricts the output to the top 10 entries.

Alternative Answer

This SQL query determines the total revenue generated each day based on transaction data. It calculates daily revenue by multiplying PRICE and QUANTITY, then using the SUM() function on these values for each day ( GROUP BY PURCHASE_DATE ). The results are ordered by date using ORDER BY PURCHASE_DATE .

Question Details

Difficulty & Category

Medium
sql

Product

For CandidatesFor RecruitersCompaniesBrowse JobsInterview QuestionsDeep ProfileSkill AssessmentOpportunity Matching
Prepin.ai

© 2026 Prepin LLC · Philadelphia, PA · All rights reserved.