El contenido no se encuentra disponible en el idioma seleccionado. Estamos trabajando continuamente para agregar más idiomas. Gracias por su apoyo.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Managed Threat Detection
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
On this page

Aggregate Functions

Updated on 2025-01-22 GMT+08:00

An aggregate function performs a calculation operation on a set of input values and returns a value. For example, the COUNT function counts the number of rows retrieved by an SQL statement. Table 1 lists aggregate functions.

Sample data: Table T1
|score|
|81   |
|100  |
|60   |
|95   |
|86   |

Common Aggregate Functions

Table 1 Common aggregate functions

Function

Return Data Type

Description

COUNT(*)

BIGINT

Return count of tuples.

COUNT([ ALL ] expression...

BIGINT

Returns the number of input rows for which the expression is not NULL. Use DISTINCT for a unique instance of each value.

AVG(numeric)

DOUBLE

Return average (arithmetic mean) of all input values.

SUM(numeric)

DOUBLE

Return the sum of all input numerical values.

MAX(value)

DOUBLE

Return the maximum value of all input values.

MIN(value)

DOUBLE

Return the minimum value of all input values.

STDDEV_POP(value)

DOUBLE

Return the population standard deviation of all numeric fields of all input values.

STDDEV_SAMP(value)

DOUBLE

Return the sample standard deviation of all numeric fields of all input values.

VAR_POP(value)

DOUBLE

Return the population variance (square of population standard deviation) of numeral fields of all input values.

VAR_SAMP(value)

DOUBLE

Return the sample variance (square of the sample standard deviation) of numeric fields of all input values.

Example

  • COUNT(*)
    • Test statement
      SELECT COUNT(score) FROM T1;
    • Test data and results
      Table 2 T1

      Test Data (score)

      Test Result

      81

      5

      100

      60

      95

      86

  • COUNT([ ALL ] expression | DISTINCT expression1 [, expression2]*)
    • Test statement
      SELECT COUNT(DISTINCT content ) FROM T1;
    • Test data and results
      Table 3 T1

      content (STRING)

      Test Result

      "hello1 "

      2

      "hello2 "

      "hello2"

      null

      86

  • AVG(numeric)
    • Test statement
      SELECT AVG(score) FROM T1;
    • Test data and results
      Table 4 T1

      Test Data (score)

      Test Result

      81

      84.0

      100

      60

      95

      86

  • SUM(numeric)
    • Test statement
      SELECT SUM(score) FROM T1;
    • Test data and results
      Table 5 T1

      Test Data (score)

      Test Result

      81

      422.0

      100

      60

      95

      86

  • MAX(value)
    • Test statement
      SELECT MAX(score) FROM T1;
    • Test data and results
      Table 6 T1

      Test Data (score)

      Test Result

      81

      100.0

      100

      60

      95

      86

  • MIN(value)
    • Test statement
      SELECT MIN(score) FROM T1;
    • Test data and results
      Table 7 T1

      Test Data (score)

      Test Result

      81

      60.0

      100

      60

      95

      86

  • STDDEV_POP(value)
    • Test statement
      SELECT STDDEV_POP(score) FROM T1;
    • Test data and results
      Table 8 T1

      Test Data (score)

      Test Result

      81

      13.0

      100

      60

      95

      86

  • STDDEV_SAMP(value)
    • Test statement
      SELECT STDDEV_SAMP(score) FROM T1;
    • Test data and results
      Table 9 T1

      Test Data (score)

      Test Result

      81

      15.0

      100

      60

      95

      86

  • VAR_POP(value)
    • Test statement
      SELECT VAR_POP(score) FROM T1;
    • Test data and results
      Table 10 T1

      Test Data (score)

      Test Result

      81

      193.0

      100

      60

      95

      86

  • VAR_SAMP(value)
    • Test statement
      SELECT VAR_SAMP(score) FROM T1;
    • Test data and results
      Table 11 T1

      Test Data (score)

      Test Result

      81

      241.0

      100

      60

      95

      86

Utilizamos cookies para mejorar nuestro sitio y tu experiencia. Al continuar navegando en nuestro sitio, tú aceptas nuestra política de cookies. Descubre más

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback