Home >Database >Mysql Tutorial >SQL语句中SUM与COUNT的区别深入分析_MySQL

SQL语句中SUM与COUNT的区别深入分析_MySQL

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOriginal
2016-06-01 13:24:34884browse

bitsCN.com

SUM是对符合条件的记录的数值列求和

COUNT 是对查询中符合条件的结果(或记录)的个数

例如:

表fruit

id     name    price

1     apple     3.00

2     pear       4.00

select count(price) from fruit; ----执行之后结果为:2  (表示有2条记录)

select  sum(price) from fruit;---执行之后结果为:7:00(表示各记录price字段之和为7.00)

 

bitsCN.com
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn