---
title: "mysql根据月份统计金额"
author: "li4haoo"
date: "2016-04-27T11:34:38Z"
tags: []
categories: ["数据库"]
slug: "mysql"
draft: false
lastmod: "2016-04-27T11:34:38Z"
id: 2294247
url: "https://lee4.iteye.com/blog/2294247"
---

select FROM\_UNIXTIME(createTime/1000,'%Y年%m月') as '时间',count(orderid) as '订单数量',sum(hasAmount\*0.01) as '订单总额' from buyorder 

where state not in(1,-1) GROUP BY FROM\_UNIXTIME(createTime/1000,'%Y年%m月')