PAU OJ Online Judge
ProblemsLearnStudy plansContestsSubmissionsRank

Updates

Announcements and upcoming contests

Loading announcements…
Sign in for personal alertsBrowse contests
Log inSign up

PAU OJ

PrimeAsia University Online Judge

A real online judge for programming practice, university contests and coding assessments. Write code in your browser, get sandboxed verdicts, and track your progress.

Platform

  • Problems
  • Contests
  • Submissions
  • Ranking
  • Reviewers

Resources

  • User guide
  • Changelog
  • How judging works
  • System health
  • Create an account

© 2026 PrimeAsia University Online Judge. All rights reserved.

v0.9.0

  1. All tracks
  2. Track 08
  3. Money & orders

Money & orders

টাকার হিসাব

Topic 02 of 106 problems
0%

Lesson progress: 0/6

solved

In this lesson

  • Concept note
    • কেন দরকার
    • মূল ধারণা
    • ধাপে ধাপে
    • কোডে দেখি
    • বাস্তব দৃশ্য
    • সাধারণ ভুল
  • Visual explainer
  • Guided practice
  • Tiered practice
    • Easy
    • Medium
    • Hard
  • Checkpoint
  • Discussion
Back to track

0/6 solved

JOIN, GROUP BY আর HAVING দিয়ে ভেন্ডরের রেভিনিউ ও প্রতিটি অর্ডারের মোট টাকা।

Work ticketSHOP-ORD-01Analytics Engineer

Vendor revenue and order receipts

ভেন্ডর রেভিনিউ ও অর্ডার রসিদ

SHOP-ORD · Order desk · Order Desk squad

অর্ডার ডেস্ক প্রতিদিন ভেন্ডরকে রেভিনিউ পাঠায় আর কাস্টমারকে অর্ডার-রসিদ দেখায়। দুই রিপোর্টের grain আলাদা—একটা ভেন্ডর-ধরে, আরেকটা অর্ডার-ধরে—তাই JOIN-এ ডুপ্লিকেট গুনা যাবে না।

Acceptance

  • শুধু `paid` আর `shipped` অর্ডার রেভিনিউ হিসেবে গোনা।
  • ভেন্ডর-ধরে `SUM(quantity * unit_price_cents)`।
  • খালি গ্রুপ বাদ দিতে `HAVING`, আর নাম দিয়ে নির্দিষ্ট ক্রম।

Tables in this ticket

  • orders
  • order_items
  • products
  • vendors
  • customers
Open the full dossier

In this lesson

  • Concept note
  • Visual explainer
  • Guided practice
  • Tiered practice
  • Checkpoint
  • Discussion
01

Step 1: Concept note

Read this first; it sets up the mental model for the problems.

Real-data story

Order receipts

Tables used

orderscustomersorder_items

Query

SELECT o.id AS order_id, c.name AS customer, SUM(oi.quantity * oi.unit_price_cents) AS total_cents FROM orders o JOIN customers c ON c.id = o.customer_id JOIN order_items oi ON oi.order_id = o.id WHERE o.status IN ('paid','shipped') GROUP BY o.id ORDER BY o.id;

Actual result from the fixture

order_idcustomertotal_cents
1Rahim890000
3Nusrat600000
4Rahim2000000
6Rahim605000
7Mim670000
8Karim180000

+ 2 more rows in the sample output.

এই সারিগুলো ShopSphere fixture থেকে আসল query চালিয়ে পাওয়া; ডায়াগ্রামে বানানো সংখ্যা নয়।

কেন দরকার

দোকান চলে টাকায়। ম্যানেজার জানতে চায় কোন ভেন্ডর কত বিক্রি করেছে, কোন অর্ডার কত টাকার, আর কোন কাস্টমার বেশি খরচ করছে। এই প্রশ্নগুলোর উত্তর এক টেবিলে থাকে না—অর্ডার, আইটেম আর প্রোডাক্ট জোড়া লাগাতে হয়।

মূল ধারণা

JOIN দুটি টেবিলের সম্পর্কিত সারি মেলায়। GROUP BY একই ভেন্ডর বা অর্ডারের সারিগুলোকে এক করে, SUM মোট বের করে। গ্রুপ করার পরে শর্ত দিতে হয় HAVING দিয়ে—WHERE নয়।

02

Step 2: Visual explainer

See the mental model first — the animation and the steps below it say the same thing.

Concept visual

JOIN করে হিসাব

টেবিল জোড়া লাগিয়ে ভেন্ডর ধরে যোগফল বের করা—JOIN আর GROUP BY ঠিক হলে রিপোর্টের সংখ্যা আসল বিক্রির সাথেই মেলে।

orders

user_idtotal
1
03

Step 3: Guided practice

Warm up with worked, story-driven problems.

Guided problems

2 problems
  • 1Vendor revenueMedium200 ptsNot attempted
04

Step 4: Tiered practice

Build control by working up from easy to hard.

Easy

1 problem
  • 1Revenue by categoryEasy150 ptsNot attempted
05

Step 5: Checkpoint

One timed attempt. Solve every problem to earn the module badge.

Final checkpoint

Ready to prove this module?

45 minutes3 problemsShopSphere Analyst badge
Go to checkpoint
06

Step 6: Discussion

Ask questions, share an approach or leave a study tip for this lesson.

Was this lesson helpful?

Your reaction helps other learners judge these notes.

Sign in to react

Discussion

0 comments

Sign in to ask a question or share an approach.

Sign in to comment

No comments yet

Be the first to ask a question or leave a study tip.

Topic 02 of 10

PreviousMeet the marketplaceদোকান চেনাTopic 01 of 10
NextMissing piecesযেখানে সারি নেইTopic 03 of 10
Back to track: Basic SQL · ShopSphereAll learning tracks
ধাপউদাহরণ
জোড়াJOIN order_items oi ON oi.order_id = o.id
যোগSUM(oi.quantity * oi.unit_price_cents)
গ্রুপ ফিল্টারHAVING SUM(...) > 500000

ধাপে ধাপে

১. কোন টেবিলগুলো লাগবে ঠিক করো। ২. JOIN-এর শর্ত লিখো। ৩. GROUP BY-তে আইডি দাও, নাম নয়। ৪. HAVING দিয়ে গ্রুপ ফিল্টার করো।

কোডে দেখি

SELECT v.name, SUM(oi.quantity * oi.unit_price_cents) AS revenue
FROM vendors v
JOIN products p ON p.vendor_id = v.id
JOIN order_items oi ON oi.product_id = p.id
GROUP BY v.id;

বাস্তব দৃশ্য

ম্যানেজার সকালের মিটিংয়ে জানতে চায়—গত মাসে কোন ভেন্ডর সবচেয়ে বেশি বিক্রি করেছে, কোন অর্ডার এখনো টাকা পায়নি, আর কোন কাস্টমার সবচেয়ে বেশি খরচ করেছে। একেক প্রশ্নের জন্য একেক ফিল্টার আর গ্রুপিং লাগে, কিন্তু কাঠামো একই: সঠিক টেবিলগুলো জোড়া লাগাও, দরকারি সারি বাদ দাও, তারপর ভেন্ডর/অর্ডার ধরে যোগ করো। ভুল টেবিলে JOIN করলে বা WHERE-এ aggregate লিখলে সংখ্যা ফুলে যায়—এই ভুলগুলোই বাস্তবে সবচেয়ে বেশি দেখা যায়।

সাধারণ ভুল

নাম দিয়ে GROUP BY করা, WHERE-এ SUM ব্যবহার, অথবা JOIN ভুল কলামে করা—এতে সংখ্যা অনেক বেড়ে যায়।

330
2120
380
JOIN ON

users

idname
1Ayesha
2Rafiq
3Nabila

joined rows

vendortotalভেন্ডর A12ভেন্ডর B8ভেন্ডর C5ভেন্ডর D3

মিলে যাওয়া key ধরে দুই table-এর row জোড়া লাগে

  1. 1সম্পর্কের চেইন চিনোvendors → products → order_items
  2. 2JOIN-এর শর্তে সারি মেলাওভুল কলামে জুড়লে সংখ্যা ফুলে যায়
  3. 3ভেন্ডর ধরে গ্রুপ করোGROUP BY-তে আইডি দাও, নাম নয়
  4. 4SUM-এ রেভিনিউ বের করোquantity গুণ দাম ধরে যোগ
  5. 5গ্রুপের শর্ত HAVING-এ দাওWHERE-এ aggregate চলে না
5টি ধাপে দেখা হচ্ছেগতি কমালে স্থির
2Order receiptsMedium200 ptsNot attempted

Medium

2 problems
  • 1Average order valueMedium200 ptsNot attempted
  • 2Items vs payments reconciliationMedium225 ptsNot attempted

Hard

1 problem
  • 1Customer spending tiersHard250 ptsNot attempted