---
title: "sql 某列当中相同的类型累加"
author: "daoshud1"
date: "2013-03-19T15:23:16Z"
tags: []
categories: ["数据库"]
slug: "sql"
draft: false
lastmod: "2013-03-19T15:23:16Z"
id: 1831851
url: "https://daoshud1.iteye.com/blog/1831851"
---

```java

select Sum(case when buy_status =1 then 1 else 0 end) '订购',
			 Sum(case when buy_status =2 then 1 else 0 end) '退订',Sum(case when buy_status =6 then 1 else 0 end) '续订'
	from business_record
GROUP BY DATE(create_time)

```

![](http://dl.iteye.com/upload/attachment/0081/8710/bdb29485-4a44-3d74-b874-aeaabaa950be.png)