SQL Having子句
SELECT
count
(
userName
)
from
`userInfo`
GROUP
BY
userName
HAVING
count
(
userName
)
>
1。
这个Having一定要放在GROUP BY的后面。
而且很特殊的情况是在有group by的时候,是不能用到where子句的。而且Having子句一般是放在其他子句的后面的。
当我们选不只一个栏位,且其中至少一个栏位有包含函数的运用时,
我们就需要用到
GROUP BY
这个指令。
SELECT "栏位1", SUM("栏位2")
from "表格名"
GROUP BY "栏位1"
HAVING (函数条件)
SELECT * from `userInfo` group by `userName` having count(userName) = 1 ;
相关文档:
create PROCEDURE pagelist
@tablename nvarchar(50),
@fieldname nvarchar(50)='*',
@pagesize int output,--每页显示记录条数
@currentpage int output,--第几页
@orderid nvarchar(50),--主键排序
@sort int,--排序方式,1表示升序,0表示降序排列
......
3。表内容如下
-----------------------------
ID LogTime
1 2008/10/10 10:00:00
1 2008/10/10 10:03:00
1 2008/10/10 10:09:00
2 2008/10/10 10:10:00
2 2008/10/10 10:11:00
......
-----------------------------
请问各位高手,如何查询登陆时间间隔不超 ......
using System;
using System.Threading;
namespace ConsoleApplication1
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
& ......
package cn.com.hbivt.util;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2005</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class StringUtils {
//过滤通过页面表单提交 ......