Can't believe it takes me so long to do a so easy thing in sql

Modified at $Date: 2005/03/09 07:11:12 $

Can't believe it takes me so long to do a so easy thing in sql.

I have to do something to make myself the best. I forgot so much... Luckily I still can write something. ^_^.

A working guy beside me want me to help him to write a query. He want to select fields in a table which has one to many relation in the field in the same table. Suppose

ClinicAddressClinic
11
21
32
43
54
65
74

select field clinic which has more than one ClinicAddress. One clinic has more than one clinicAddress. How to do this in Query Analyzer.

sql query is below.

SELECT clinic, COUNT(*) as countNumber
FROM clinic_address
GROUP BY clinic
HAVING COUNT(*) > 1
ORDER BY countNumber

Use HAVING clause to make it. Easy? But why I forgot it??? What a shame to me!

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值