ROLLUP का उपयोग
ROLLUP एक grouped result में subtotal और grand total rows add करता है।
In this page:
Syntax
SELECT column1, column2, aggregate_function(column)
FROM table_name
GROUP BY ROLLUP (column1, column2);
ROLLUP
GROUP BY ROLLUP (a, b) (a, b) के लिए groups produce करता है, फिर (a) के लिए subtotals और () के लिए एक grand total।
Subtotal rows rolled-up columns में NULL दिखाती हैं। GROUPING() function real NULLs को subtotal NULLs से अलग बताता है।
यह reports के लिए PostgreSQL syntax है; site editor का SQLite इसे support नहीं करता।
Note:
Subtotal rows label करने के लिए GROUPING(col) इस्तेमाल करें।
उदाहरण: ROLLUP
shop=# SELECT region, item, SUM(qty) AS total
shop-# FROM sales GROUP BY ROLLUP (region, item) ORDER BY region, item;
region | item | total
--------+------+-------
N | book | 1
N | lamp | 2
N | pen | 5
N | | 8
S | book | 3
S | pen | 10
S | | 13
| | 21
⚠️ Run this in your own terminal or Node.js environment.
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the
view already swaps in the hi_ translation fields (or blanks these
out if untranslated), so this renders correctly for both languages
without a lang_code check here. #}
आम गलतियां
- subtotal NULLs को data NULLs से confuse करना
- इसे SQLite में expect करना
- ORDER BY भूल जाना
चैप्टर सारांश
- ROLLUP subtotals और एक grand total add करता है
- Subtotal rows में NULL है
- GROUPING() इन्हें identify करता है
- Report totals के लिए great
🔒
Chapter Quiz — Complete all 7 topics to unlock
0/7 topics done
Complete these topics first: