Home > Database > Mysql Tutorial > sqlserver 一张表两列都的值都相同处理

sqlserver 一张表两列都的值都相同处理

WBOY
Release: 2016-06-07 15:46:09
Original
1452 people have browsed it

欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入 今天业务需要,网上没找到 最后写出来了就留个印以备查阅 #T1表中 A,B 列 至少三行都相同的数据 SELECT * FROM #T1 t1 WHERE ( SELECT COUNT(*) FROM( SELECT DISTINCT A,B FROM #T1 WHERE A=t

欢迎进入Windows社区论坛,与300万技术人员互动交流 >>进入

  今天业务需要,网上没找到  最后写出来了就留个印以备查阅

  #T1表中 A,B 列 至少三行都相同的数据

  SELECT * FROM #T1 t1 WHERE

  (

  SELECT COUNT(*) FROM(

  SELECT DISTINCT A,B FROM #T1 WHERE A=t1.A

  ) A

  )=1

  AND (SELECT DISTINCT COUNT(ID) FROM #T1 WHERE A=t1.A)>=3

  ORDER BY t1.A

sqlserver 一张表两列都的值都相同处理

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