Tech TutorBangla Web Documentation
Portfolio
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • PrismaPostgres Documentation40টি অধ্যায়
প্রযুক্তি নির্বাচন
HomeHTMLCSSTailwind CSSJavaScriptTypeScriptReactNext.jsNode.jsExpressSocket.IOExpoWordPressPostgreSQLPrismaPostgresNestJSMongoDBDockerTanStackTanStack TableRTK QueryGitGitHub
  • Prisma Intro
  • Prisma vs Raw SQL
  • Setup & Install
  • Schema Basics
  • Models
  • Relations
  • Migrations
  • Prisma Client
  • Create & Upsert
  • Read Queries
  • Update & Delete
  • Query Filters
  • Sort & Pagination
  • Select & Include
  • Nested Writes
  • Transactions
  • Aggregation
  • JSON Fields
  • Raw SQL
  • TechShop Schema
  • TechShop Seed
  • Relations Advanced
  • Env Config
  • Global Client
  • Next.js + Prisma
  • Express API
  • Error Handling
  • Performance
  • Connection Pool
  • Prisma Studio
  • Deploy Migrations
  • TechShop Indexes
  • TechShop Cart
  • TechShop Stats API
  • Schema Evolution
  • Debugging
  • Common Mistakes
  • Best Practices
  • Interview Questions
  • Recap & Next
  1. Docs
  2. PrismaPostgres
  3. Dashboard stats — aggregate + groupBy
PrismaPostgresIntermediate

Dashboard stats — aggregate + groupBy

admin dashboard-এর numbers — count, sum, group।

4টি অংশবাংলা ভাষায়
await prisma.order.aggregate({
  where: {
    status: "paid",
    createdAt: { gte: thirtyDaysAgo },
  },
  _count: { _all: true },
  _sum: { total: true },
});
const popular = await prisma.orderItem.groupBy({
  by: ["productId"],
  _sum: { qty: true },
  orderBy: { _sum: { qty: "desc" } },
  take: 5,
});

// productId → name join সহজ
const names = await prisma.product.findMany({
  where: { id: { in: popular.map((p) => p.productId) } },
});
StatAPI
মোট order/revenuecount + _sum aggregate
জনপ্রিয় পণ্যgroupBy _sum qty
category-countgroupBy categoryId
monthly trendraw-sql date_trunc
rewrite SQL

অধিকাংশ stat-এ groupBy/aggregate-ই যথেষ্ট; date-series/জটিল report-এ $queryRaw (json_agg) আরও পরিষ্কার।

শেষ প্যারায় নিজে practice করুন — কোড কপি করে নিজের এডিটরে চালিয়ে দেখুন।
আগেরOrder creation — stock + transactionপরেরবড় schema-পরিবর্তন — data migration
Tech Tutor

বাংলায় ওয়েব ডেভেলপমেন্ট ডকুমেন্টেশন শিখুন — ধাপে ধাপে।

Homeসব ডকুমেন্টেশনQuick Startআমার নোটস

© 2026 Tech Tutor. বাংলায় শিখুন, বাংলায় গড়ুন।

mdanamolhasan1998@gmail.com