|
发表于 2020-1-25 15:09:01
|
显示全部楼层
create table g_applydetail(g_applyno char(3), g_name nvarchar(10), g_cardid varchar(10))
insert g_applydetail select '001', '张三', '350124'
union all select '002', '李四', '370103'
union all select '003', '王五', '430105'
union all select '004', '张三', '350124'
select g_cardid, num=count(g_cardid)
from g_applydetail
group by g_cardid
having count(g_cardid)>1
---result
g_cardid num
---------- -----------
350124 2
(1 row(s) affected) |
|