{
    "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max",
    "locale": "en",
    "title": "COUNT / SUM / AVG / MIN / MAX: Knowledge hub | DeLaParra Services",
    "description": "The standard aggregate functions. COUNT(*) counts rows; COUNT(col) ignores NULLs; the rest reduce a column to one value.",
    "alternates": {
        "en": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max",
        "nl": "https://delaparra-services.nl/nl/kennisbank/count-sum-avg-min-max"
    },
    "formats": {
        "csv": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.csv",
        "md": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.md",
        "json": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.json",
        "zip": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.zip",
        "pdf": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.pdf"
    },
    "downloads": [
        {
            "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.csv",
            "encodingFormat": "text/csv",
            "name": "count-sum-avg-min-max.csv"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.json",
            "encodingFormat": "application/json",
            "name": "count-sum-avg-min-max.json"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.md",
            "encodingFormat": "text/markdown",
            "name": "count-sum-avg-min-max.md"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.pdf",
            "encodingFormat": "application/pdf",
            "name": "count-sum-avg-min-max.pdf"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.zip",
            "encodingFormat": "application/zip",
            "name": "count-sum-avg-min-max.zip"
        },
        {
            "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max/skills.zip",
            "encodingFormat": "application/zip",
            "name": "count-sum-avg-min-max-skills.zip"
        }
    ],
    "markdown": "1. [Home](<https://delaparra-services.nl/>) \n1. [Knowledge hub](<https://delaparra-services.nl/knowledge-hub>) \n1. [COUNT / SUM / AVG / MIN / MAX](<https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max>)\n\n  \n\nCategory: SQL \n\n# COUNT / SUM / AVG / MIN / MAX\n\n  Explained by [Reinier de la Parra](<https://delaparra-services.nl/about>)  Updated November 25, 2026    \n\n## What is COUNT / SUM / AVG / MIN / MAX?\n\n \n\nCOUNT / SUM / AVG / MIN / MAX: The standard aggregate functions. COUNT(\\*) counts rows; COUNT(col) ignores NULLs; the rest reduce a column to one value. ` COUNT `, ` SUM `, ` AVG `, ` MIN ` and ` MAX ` are SQL's aggregate functions. They reduce many rows to one value: how many orders, the total revenue, the average order size, the cheapest and most expensive product.\n\n \n\nDefinition source [Coders Lingo](<https://coderslingo.com/resources/open-dataset/>), [CC BY 4.0](<https://creativecommons.org/licenses/by/4.0/>)\n\n \n\n## Frequently asked questions about COUNT / SUM / AVG / MIN / MAX\n\n  \n\n### How is COUNT / SUM / AVG / MIN / MAX used in practice?\n\n \n\nCombined with ` GROUP BY `, they become the basis of most reports. ` SELECT customer_id, SUM(total) FROM orders GROUP BY customer_id ` gives revenue per customer in one query.\n\n    \n\n### What should you keep in mind with COUNT / SUM / AVG / MIN / MAX?\n\n \n\nWatch how they treat ` NULL `. ` COUNT(*) ` counts all rows, but ` COUNT(column) ` skips rows where that column is ` NULL `. ` AVG ` ignores nulls too, which can make an average look higher than you expect. Doing these calculations in the database is almost always much faster than loading every row into PHP or JavaScript and adding them up there.\n\n    \n\n### What does an example of COUNT / SUM / AVG / MIN / MAX look like?\n\n \n\n```\nSELECT COUNT(*), SUM(total), AVG(total), MIN(total), MAX(total) FROM orders;\n```\n\n \n\n## At a glance\n\n   CategorySQL Explained by[Reinier de la Parra](<https://delaparra-services.nl/about>) UpdatedNovember 25, 2026\n\n \n\n## More SQL terms\n\n \n\n- [CASE](<https://delaparra-services.nl/knowledge-hub/case>) \n- [COALESCE](<https://delaparra-services.nl/knowledge-hub/coalesce>) \n- [composite index](<https://delaparra-services.nl/knowledge-hub/composite-index>) \n- [covering index](<https://delaparra-services.nl/knowledge-hub/covering-index>) \n- [CROSS JOIN](<https://delaparra-services.nl/knowledge-hub/cross-join>) \n- [CTE (WITH)](<https://delaparra-services.nl/knowledge-hub/cte-with>)\n\n \n\n[All terms starting with C](<https://delaparra-services.nl/knowledge-hub#letter-c>)\n\n \n\n## Skills\n\n \n\n- ### SQL Performance Optimization Assistant\n\n \n\n'Universal SQL performance optimization assistant for comprehensive query tuning, indexing strategies, and database performance analysis across all SQL databases (MySQL, PostgreSQL, SQL Server, Oracle). Provides execution plan analysis, pagination optimization, batch operations, and performance monitoring guidance.'\n\n [View skill](<https://delaparra-services.nl/skills/sql-optimization>) [Download zip](<https://delaparra-services.nl/skills/sql-optimization/download>) \n- ### SQL Code Review\n\n \n\n'Universal SQL code review assistant that performs comprehensive security, maintainability, and code quality analysis across all SQL databases (MySQL, PostgreSQL, SQL Server, Oracle). Focuses on SQL injection prevention, access control, code standards, and anti-pattern detection. Complements SQL optimization prompt for complete development coverage.'\n\n [View skill](<https://delaparra-services.nl/skills/sql-code-review>) [Download zip](<https://delaparra-services.nl/skills/sql-code-review/download>) \n- ### Laravel Database Optimization\n\n \n\nLaravel database optimization patterns. Use when writing Eloquent queries, creating migrations, configuring caching, debugging slow queries, or optimizing database performance. Triggers on tasks involving N+1 queries, indexing, Redis caching, pagination, or database transactions.\n\n [View skill](<https://delaparra-services.nl/skills/laravel-database-optimization>) [Download zip](<https://delaparra-services.nl/skills/laravel-database-optimization/download>)\n\n [Download all skills (zip)](<https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max/skills.zip>)\n\n \n\n## Manuals\n\n \n\n- [Writing SQL queries and migrations](<https://delaparra-services.nl/manuals/sql-queries-en-migraties>) \n- [PHP and Composer](<https://delaparra-services.nl/manuals/php-en-composer>)\n\n \n\n## Related services\n\n \n\n- [Custom software and web applications](<https://delaparra-services.nl/services#service-03>)\n\nPerhaps your customers need somewhere to download their invoices, or your staff are managing bookings in a spreadsheet. \n- [AI code review](<https://delaparra-services.nl/services#service-05>)\n\nWhen you push your new change, I will review your code, help your agent avoid the same mistake again, and get your app ready for deployment.\n\n \n\n## Need any help?\n\n \n\nStuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.\n\n  [Get in touch](<https://delaparra-services.nl/availability>)\n\n[HTML version](https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max)\n",
    "structured_data": {
        "@context": "https://schema.org",
        "@graph": [
            {
                "@type": "Organization",
                "@id": "https://delaparra-services.nl/#practice",
                "logo": "https://delaparra-services.nl/logo.png",
                "name": "DeLaParra Services",
                "legalName": "DeLaParra Services",
                "url": "https://delaparra-services.nl/",
                "description": "Bespoke software, web applications and mobile apps, developed in Laravel by a single developer in Groningen. Fixed price agreed in advance, full source code provided upon delivery.",
                "email": "info@delaparra-services.nl",
                "address": {
                    "@type": "PostalAddress",
                    "addressLocality": "Groningen",
                    "addressRegion": "Groningen",
                    "addressCountry": "NL"
                },
                "areaServed": "Groningen, the Netherlands",
                "knowsLanguage": [
                    "en",
                    "nl"
                ],
                "knowsAbout": [
                    "Web design and development",
                    "App development",
                    "Custom software and web applications",
                    "OpenSpec",
                    "AI code review",
                    "Your own coding agent"
                ],
                "founder": {
                    "@id": "https://delaparra-services.nl/#person"
                }
            },
            {
                "@type": "FAQPage",
                "@id": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#webpage",
                "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max",
                "name": "COUNT / SUM / AVG / MIN / MAX: Knowledge hub | DeLaParra Services",
                "description": "The standard aggregate functions. COUNT() counts rows; COUNT(col) ignores NULLs; the rest reduce a column to one value.",
                "isPartOf": {
                    "@id": "https://delaparra-services.nl/#website"
                },
                "about": {
                    "@type": "DefinedTerm",
                    "@id": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#term",
                    "name": "COUNT / SUM / AVG / MIN / MAX",
                    "description": "The standard aggregate functions. COUNT(*) counts rows; COUNT(col) ignores NULLs; the rest reduce a column to one value.",
                    "termCode": "count-sum-avg-min-max",
                    "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max",
                    "inLanguage": "en",
                    "keywords": "SQL",
                    "dateModified": "2026-11-25T17:46:25+00:00",
                    "inDefinedTermSet": {
                        "@id": "https://delaparra-services.nl/knowledge-hub#terms"
                    },
                    "isPartOf": {
                        "@id": "https://delaparra-services.nl/knowledge-hub#dataset"
                    },
                    "subjectOf": [
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#webpage"
                        },
                        {
                            "@id": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#dataset"
                        }
                    ]
                },
                "inLanguage": "en",
                "breadcrumb": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#breadcrumb"
                },
                "mainEntity": [
                    {
                        "@type": "Question",
                        "name": "What is COUNT / SUM / AVG / MIN / MAX?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "The standard aggregate functions. COUNT(*) counts rows; COUNT(col) ignores NULLs; the rest reduce a column to one value. COUNT, SUM, AVG, MIN and MAX are SQL's aggregate functions. They reduce many rows to one value: how many orders, the total revenue, the average order size, the cheapest and most expensive product."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "How is COUNT / SUM / AVG / MIN / MAX used in practice?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "Combined with GROUP BY, they become the basis of most reports. SELECT customer_id, SUM(total) FROM orders GROUP BY customer_id gives revenue per customer in one query."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What should you keep in mind with COUNT / SUM / AVG / MIN / MAX?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "Watch how they treat NULL. COUNT(*) counts all rows, but COUNT(column) skips rows where that column is NULL. AVG ignores nulls too, which can make an average look higher than you expect. Doing these calculations in the database is almost always much faster than loading every row into PHP or JavaScript and adding them up there."
                        }
                    },
                    {
                        "@type": "Question",
                        "name": "What does an example of COUNT / SUM / AVG / MIN / MAX look like?",
                        "acceptedAnswer": {
                            "@type": "Answer",
                            "text": "SELECT COUNT(*), SUM(total), AVG(total), MIN(total), MAX(total) FROM orders;"
                        }
                    }
                ],
                "author": {
                    "@id": "https://delaparra-services.nl/#person"
                },
                "mentions": [
                    {
                        "@id": "https://delaparra-services.nl/skills/sql-optimization#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/skills/sql-code-review#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/skills/laravel-database-optimization#skill"
                    },
                    {
                        "@id": "https://delaparra-services.nl/manuals/sql-queries-en-migraties#article"
                    },
                    {
                        "@id": "https://delaparra-services.nl/manuals/php-en-composer#article"
                    }
                ]
            },
            {
                "@type": "BreadcrumbList",
                "@id": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#breadcrumb",
                "itemListElement": [
                    {
                        "@type": "ListItem",
                        "position": 1,
                        "name": "Home",
                        "item": "https://delaparra-services.nl/"
                    },
                    {
                        "@type": "ListItem",
                        "position": 2,
                        "name": "Knowledge hub",
                        "item": "https://delaparra-services.nl/knowledge-hub"
                    },
                    {
                        "@type": "ListItem",
                        "position": 3,
                        "name": "COUNT / SUM / AVG / MIN / MAX"
                    }
                ]
            },
            {
                "@type": "Person",
                "@id": "https://delaparra-services.nl/#person",
                "name": "Reinier de la Parra",
                "url": "https://delaparra-services.nl/about"
            },
            {
                "@type": "Dataset",
                "@id": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#dataset",
                "name": "COUNT / SUM / AVG / MIN / MAX",
                "description": "The standard aggregate functions. COUNT(*) counts rows; COUNT(col) ignores NULLs; the rest reduce a column to one value.",
                "url": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max",
                "identifier": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#dataset",
                "about": {
                    "@id": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max#term"
                },
                "creator": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "publisher": {
                    "@id": "https://delaparra-services.nl/#practice"
                },
                "license": "https://creativecommons.org/licenses/by/4.0/",
                "creditText": "Coders Lingo (https://coderslingo.com/resources/open-dataset/), CC BY 4.0",
                "isAccessibleForFree": true,
                "inLanguage": "en",
                "keywords": "SQL",
                "version": "2026-11-25",
                "dateModified": "2026-11-25T17:46:25+00:00",
                "isPartOf": {
                    "@type": "Dataset",
                    "@id": "https://delaparra-services.nl/knowledge-hub#dataset",
                    "name": "IT terms from A to Z",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "includedInDataCatalog": {
                    "@type": "DataCatalog",
                    "@id": "https://delaparra-services.nl/knowledge-hub#catalog",
                    "name": "Knowledge hub data catalog",
                    "url": "https://delaparra-services.nl/knowledge-hub"
                },
                "distribution": [
                    {
                        "@type": "DataDownload",
                        "name": "count-sum-avg-min-max.csv",
                        "encodingFormat": "text/csv",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.csv",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "count-sum-avg-min-max.json",
                        "encodingFormat": "application/json",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.json",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "count-sum-avg-min-max.md",
                        "encodingFormat": "text/markdown",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.md",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "count-sum-avg-min-max.pdf",
                        "encodingFormat": "application/pdf",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.pdf",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "count-sum-avg-min-max.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    },
                    {
                        "@type": "DataDownload",
                        "name": "count-sum-avg-min-max-skills.zip",
                        "encodingFormat": "application/zip",
                        "contentUrl": "https://delaparra-services.nl/knowledge-hub/count-sum-avg-min-max/skills.zip",
                        "inLanguage": "en",
                        "dateModified": "2026-11-25T17:46:25+00:00",
                        "license": "https://creativecommons.org/licenses/by/4.0/"
                    }
                ]
            }
        ]
    }
}