其他语言

本类阅读TOP10

·基于Solaris 开发环境的整体构思
·使用AutoMake轻松生成Makefile
·BCB数据库图像保存技术
·GNU中的Makefile
·射频芯片nRF401天线设计的分析
·iframe 的自适应高度
·BCB之Socket通信
·软件企业如何实施CMM
·入门系列--OpenGL最简单的入门
·WIN95中日志钩子(JournalRecord Hook)的使用

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
Can't believe it takes me so long to do a so easy thing in sql

作者:未知 来源:月光软件站 加入时间:2005-5-13 月光软件站

Modified at $Date: 2005/03/09 07:11:12 $
<h2>Can't believe it takes me so long to do a so easy thing in sql.</h2>

<p>
I have to do something to make myself the best. I forgot so much... Luckily I still can write something. ^_^.
</p>
<p>
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
<table border="1">
    <tr><td>ClinicAddress</td><td>Clinic</td></tr>
    <tr><td>1</td><td>1</td></tr>
    <tr><td>2</td><td>1</td></tr>
    <tr><td>3</td><td>2</td></tr>
    <tr><td>4</td><td>3</td></tr>
    <tr><td>5</td><td>4</td></tr>
    <tr><td>6</td><td>5</td></tr>
    <tr><td>7</td><td>4</td></tr>
</table>
</p>

<p>
select field clinic which has more than one ClinicAddress. One clinic has more than one clinicAddress. How to do this in Query Analyzer.
</p>
<p>
sql query is below.
<pre>
<font color="#66cd00">SELECT</font> clinic, COUNT(*) as countNumber
<font color="#66cd00">FROM</font> clinic_address
<font color="#66cd00">GROUP BY</font> clinic
<font color="#66cd00">HAVING COUNT(*)</font> > 1
<font color="#66cd00">ORDER BY</font> countNumber
</pre>
</p>
<p>
Use <font color="#66cd00"><i>HAVING</i></font> clause to make it. Easy? But why I forgot it???
What a shame to me!
</p>




相关文章

相关软件