使用人数统计的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
相关问答:
执行的顺序:
1)文件浏览框(选择文件使用)
选择好文件后
点击一个导入按钮的时候 ,把上面上传框里的csv文件以一个ID为文件名,上传到**/**文件夹下
2)读取这个文件夹下的csv的文件,转换成sql
3 ......
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
org.apache.jas ......
现在有两张表:文章主表A(articleId,articleTitle),文章评论表B(commentId,articleId,commentTitle)
现在我想实现这样的功能:列出文章列表,其中每篇文章标题下面列出此文章的前2个文章评论,请问sql语句怎么写啊 ......
如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP
参考:http://hi.baidu.com/toiota ......
现在有一个部门表dept(部门名称,部门号。。)有一个人员表emp(姓名,人员编号,职位,薪资,部门)
emp表中的内容是这样的:
a 1 工程师 3000 软件部
b 2 普通员工 2000 硬件部
c 3 工程师 4000 硬件部
d ......