sql查询,牛人快进 - MS-SQL Server / 基础类
有表table1
SQL code:
uid time url
1 1 th
1 2 th
3 2 io
2 3 yu
4 1 th
1 8 io
2 9 yu
1 7 yu
用户 1 从 th 出来的时间是1和2,然后又在时间 7 时去了yu ,在时间 8 时去了io,要查出他从1出来后最早去了那儿?结果就是yu。统计从th出来去其他url的人数并排名!!
最终结果:
SQL code:
url '人数'
yu 2 --这里面的两个人是uid:1和2
io 1 --uid:3
不明白?我再解释~~~
不明白,没有看明白什么意思
io 1 --uid:3
3并没有访问th,为什么统计上了
SQL code:
url '人数'
yu 2 --这里面的两个人是uid:1和2
io 1 --uid:3
uid 为2的用户没有去过th啊??
谁知道怎么算出来,怎么算进去
SQL code:
select url,count(distinct uid) as '人数'
from table1 a
where exists (
select 1 from table1
where url='th'
and time < a.time
and uid=a.uid
)
group by url
结果应该是
url '人数'
yu 1 --uid:1
&nbs
相关问答:
我一个项目,有个插入操作,具体是这样的:
我有进货信息表。在出货时选择相应的进货信息,输入数量,选择部门后,点保存按钮,由于网络延时,点一下没有反映,于是用户就又点一下,导致一次插入了两条记录:
例:
......
sql的软件在哪里可以下啊!在网上找了蛮多都用不了啊
随便搞一D版吧,
迅雷第一个就可以用
2000,2005都这样
http://119.147.41.16/down?cid=0698C2D64D7D637D90A6D2482298E6717D4F15CD&t=2&fmt=-1 ......
tab1 字段:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 字段:goodsid,goodskind(商品类型)
tab3 字段:goodskind(商品类型),kindname
结果:
得到商品类型在一段时间 ......