Home > Backend Development > PHP Tutorial > mysql数据有关问题 grounp by 行不行

mysql数据有关问题 grounp by 行不行

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-13 12:15:04
Original
1225 people have browsed it

mysql数据问题 grounp by 行不行?

表table,字段如图
我想取得d_consutotal的总和,但是条件是要FROM_UNIXTIME(d_inputdate,'%Y-%m')='2015-02' AND d_adaccount='1',并且按条件来,相同的d_consutotal只取一个(要的结果就是3055.52+1111.11.........),现在这所有的d_inputdate转换后都是"2015-02'"了。
请问这语句该怎么写呢?
------解决思路----------------------
求和用 sum 函数
对 d_consutotal 求和,写作 sum(d_consutotal)
相同的d_consutotal只取一个,则写作 sum(DISTINCT d_consutotal)

既然你有 FROM_UNIXTIME(d_inputdate,'%Y-%m')='2015-02' AND d_adaccount='1' 的条件约束,自然只会得到 2015 年 2 月的数据结果

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template