---
title: "having子句使用 -- SQL查询不重复的记录集"
author: "wing123"
date: "2010-08-29T13:09:36Z"
tags: ["SQL"]
categories: ["企业架构"]
slug: "having-sql"
draft: false
lastmod: "2010-08-29T13:09:36Z"
id: 750048
url: "https://wing123.iteye.com/blog/750048"
---

需求：如题所说，例：表A中有字段（id,no），其中记录为

1  --  1

2  --  1

3  --  2

4  --  3

5  --  4

6  --  3

7  --  1

 

想获取的结果集是

3  -- 2

5  -- 4

 

SQL的写法就是group by no having count(\*)=1