⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 458.html

📁 Jsp001精华文章离线版.很不错的,主要是针对JSP的相关内容的
💻 HTML
字号:

<STYLE type=text/css>
<!--
body,td { font-size:9pt;}
hr { color: #000000; height: 1px}
-->
</STYLE>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<HTML>
<HEAD><TITLE>FAQ汇萃 >> SQL之家 >> 如何在SQL数据库中得到重复次数最多的记录</title>
</head>
<body >

<p><IMG SRC="../image/jsp001_middle_logo.gif" WIDTH="180" HEIGHT="60" BORDER=0 ALT=""></p>

<table width=100% bgcolor="#cccccc" align=center cellpadding="2" cellspacing="0" border=1 bordercolorlight="#000000" bordercolordark="#FFFFFF">
<tr bgcolor="#EFF8FF"><td>
<a href=http://www.jsp001.com/list_thread.php?int_attribute=1>FAQ汇萃</a>
>> <a href=http://www.jsp001.com/list_thread.php?forumid=45&int_attribute=1>SQL之家</a>
>> 如何在SQL数据库中得到重复次数最多的记录 [<a href=http://www.jsp001.com/forum/showthread.php?goto=newpost&threadid=458>查看别人的评论</a>]<br>

<hr><p>由 amtd 发布于: 2001-02-15 09:49</p><p><img src="images/icons/icon1.gif" alt="Post" border=0> </p><p><br><br>  接着昨天没有写完的那个无重复的随即数字的程序,我们展开来讲!既然做这个程序的的目的是为了对<br>买彩票的程序作准备!所以我要把 每次 的结果保存到SQL server 数据库中!<br>我的想法是首先运行100万次摇奖的程序后,将这100万条数据存放到数据库中,然后用SQL语句选择出重复次数<br>最多的一组数据,这个就是我的想法!大家仅仅是参考,千万不要模仿呀:)<br>前面我们已经说过如何生成不重复的随即数,我们就利用那个函数来生成一组数据,如此重复100万次!经过3个小时<br>的运算以后,我们得到了一组巨大的记录,下面我们来看看 如何得到 重复次数最多的一组号码呢?<br>我们以前曾经讲过,使用distinct 可以使我们得到一个不重复的记录集(select distinct * from table1),<br>那么怎么得到有重复的记录集呢,显然 简单的使用关键字是不可能实现的了,豆腐最终确定使用Having子句来实现<br>这样的功能,SQL 语句如下,select * from table1 having count(*)&gt;1 这样我们就得到了一个所有记录重复次数超过<br>一次的记录集,我们利用如下语句 select count(*) ccount from table1 group by a1,a2,a3,a4,a5,a6,a7 having <br>count(*)&gt;! order by ccount desc<br>这样得到的第一个记录就是出现重复次数最多的那组数字。<br>/*<br>豆腐制作 都是精品<br><a href="http://www.asp888.net" target=_blank>http://www.asp888.net</a> 豆腐技术站<br>如转载 请保留完整版权信息<br>*/ <br> <br><br>__________________<br><font color=red>真实源于生活! </font><br>请访问我们的网站: <br>(VB爱好者乐园) <br><a href="http://www.vbgood.com" target=_blank>http://www.vbgood.com</a><br><a href="http://www.d1vb.com" target=_blank>http://www.d1vb.com</a><br><a href="http://61.128.97.225/vbgood/index.asp" target=_blank>http://61.128.97.225/vbgood/index.asp</a><br>拥有1800多个资料! </p></td>
  </tr>
</table>

<p>
<CENTER><a href="http://www.jsp001.com/forum/newreply.php?action=newreply&threadid=458">点这里对该文章发表评论</a></CENTER>
<p>该文章总得分是 <font color=red>6</font> 分,你认为它对你有帮助吗?
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=458&intVote=4","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>非常多</a>](<font color=red>1</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=458&intVote=2","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>有一些</a>](<font color=red>1</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=458&intVote=1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>无帮助</a>](<font color=red>1</font>) 
				[<a href=javascript:void(0) onclick=window.open("http://www.jsp001.com/forum/codeVote.php?threadid=458&intVote=-1","","menubar=no,toolbar=no,location=no,directories=no,status=no,resizable=no,scrollbars=no,width=70,height=40,top=0,left=0")>是灌水</a>](<font color=red>1</font>) </p>
<script language="javascript" src="http://www.jsp001.com/include/read_thread_script.php?threadid=458"></script>
<p><CENTER>
Copyright &copy; 2001 - 2009 JSP001.com . All Rights Reserved <P>

<IMG SRC="../image/jsp001_small_logo.gif" WIDTH="85" HEIGHT="30" BORDER=0 ALT="">
</CENTER></p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -