赞
踩
题目描述:

编写一个SQL查询语句,查找那些应该被禁止的Leetflex帐户编号account_id。 如果某个帐户在某一时刻从两个不同的网络地址登录了,则这个帐户应该被禁止。
可以以任何顺序返回结果。
查询结果格式如下例所示:

Account ID 1 --> 该账户从 “2021-02-01 09:00:00” 到 “2021-02-01 09:30:00” 在两个不同的网络地址(1 and 2)上激活了。它应该被禁止.
Account ID 2 --> 该账户在两个不同的网络地址 (6, 7) 激活了,但在不同的时间上.
Account ID 3 --> 该账户在两个不同的网络地址 (9, 13) 激活了,虽然是同一天,但时间上没有交集.
Account ID 4 --> 该账户从 “2021-02-01 17:00:00” 到 “2021-02-01 17:00:00” 在两个不同的网络地址 (10 and 11)上激活了。它应该被禁止.
方法1:
主要思路:解题链接汇总
select distinct l2.account_id as account_id
from LogInfo as l1 ,LogInfo as l2
where l1.account_id=l2.account_id and l1.ip_address<>l2.ip_address and l1.login>=l2.login and l1.login<=l2.logout
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。