易截截图软件、单文件、免安装、纯绿色、仅160KB

使用人数统计的SQL - MS-SQL Server / 疑难问题

SQL code:

create table #tb1(ip nvarchar(20),date datetime)
insert into #tb1
select '10.110.120.114','2010-04-01 03:57:49' union all
select '10.119.123.130','2010-04-01 04:01:22' union all
select '10.110.120.114','2010-04-01 04:04:51' union all
select '10.110.120.114','2010-04-01 04:11:42' union all
select '10.128.130.110','2010-04-01 04:04:51' union all
select '10.110.120.114','2010-04-01 06:48:42' union all
select '10.110.120.114','2010-04-01 06:57:45' union all



求实际使用人数.
以第一次出现的IP为准(group by IP),半小时内的都当做他一直在使用,半小时后出现的才算第二次使用。
以10.110.120.114举例,第一次是 03:57:49,此后半小时内出现的 04:04:51\04:11:42就不做统计了.(03:57:49)的半小时后最近的一个也就是 06:48:42,用它再做起点,06:57:45就又不统计……以此类推
求个IP实用的次数
结果应该是这样的

ip counts
-------------- -----------
10.110.120.114 2
10.119.123.130 1
10.128.130.110 1
SQL code:
create table #tb1(ip nvarchar(20),date datetime)
insert into #tb1
select '10.110.120.114','2010-04-01 03:57:49' union all
select '10.119.123.130','2010-04-01 04:01:22' union all
select '10.110.120.114','2010-04-01 04:04:51' union all
select '10.110.120.114','2010-04-01 04:11:42


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

一条 SQL - Oracle / 基础和管理

有这样一条SQL
 Select Get_Costtaxrate(col1), Get_Tcostvalue(col1) from a
 
其中Get_Costtaxrate、Get_Tcostvalue都是函数,这两个函数里面都是查找一个大表,Get_Tcostvalue还需要调用Get_C ......

Access通过Sql语句创建数据库 - .NET技术 / C#

在Access的查询中执行下面的语句,无效,提示期待select ,updata ,...
CreateTble C=Answer N="回帖表"
(
  C=ID T="INTEGER" P=No M=No N="编号" Z=false,
  C=Ques ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号