TGViewer
Data Analysis Books | Python | SQL | Excel | Artificial Intelligence | Power BI | Tableau | AI Resources Data Analysis Books | Python | SQL | Excel | Artificial Intelligence | Power BI | Tableau | AI Resources @learndataanalysis · 53.3K subscribers
Post #2132 7.52K
🧠 SQL Interview Question (Category Contribution % - Tricky)
📌

sales(category, product_id, revenue)

❓ Ques :

👉 For each category, calculate percentage contribution of each product’s revenue within that category

👉 Return category, product_id, revenue, contribution_percentage

🧩 How Interviewers Expect You to Think

• Calculate total revenue per category 📊
• Divide product revenue by category total
• Use window functions (SUM OVER)

💡 SQL Solution

SELECT
category,
product_id,
revenue,
(revenue * 100.0) / SUM(revenue) OVER (
PARTITION BY category
) AS contribution_percentage
FROM sales;

🔥 Why This Question Is Powerful

• Tests real business KPI calculation skills 🧠
• Evaluates understanding of window functions with aggregation
• Very common in Amazon, Flipkart, analytics roles

❤️ React if you want more real interview-level SQL questions 🚀
  • ❤ 14
  • 🔥 1
More from @learndataanalysis
  1. Sep 23, 2026✅ Types of Machine Learning Algorithms 🤖📊 1️⃣ Supervised Learning Supervised learning me…
  2. Sep 19, 2026🚀 GigaChat 3.5 Reasoning — a new open-source LLM that thinks before it answers. It breaks…
  3. Sep 16, 2026🟠 Part 12 — Dashboard Development • Dashboard layout, Tiled vs Floating, Containers, Devi…
  4. Sep 16, 2026📊 Tableau Learning Roadmap 2026 If you're starting Tableau from scratch, follow this orde…
  5. Sep 6, 2026UNPOPULAR OPINION: Excel is still relevant for data analysis. I am often asked by junior d…
  6. Aug 28, 2026✅ Power BI Basics 📊🚀 👉 Power BI is one of the most popular Business Intelligence BI too…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →