需要 IP 重复查询

你好,我在论坛、GitHub 和谷歌上搜索了,但未能找到用于搜索重复 IP 地址的 #plugin:data-explorer 查询语句。有人可以分享一个吗?

1 个赞
WITH users_per_ip AS (
SELECT
count(1) AS user_count,
u.registration_ip_address AS ip,
max(u.created_at) last_create,
min(u.created_at) first_create,
(max(u.created_at) - min(u.created_at)) diff,
case when (max(u.suspended_at) is not null 
      or max(u.silenced_till) is not null )
      then 1 else 0 end bad
FROM users u
GROUP BY ip
)

SELECT
u.id AS user_id,
date_trunc('day',u.created_at)::date created,
date_trunc('day',upi.diff) days,
bad,
upi.ip AS ip_address
FROM users_per_ip upi
JOIN users u
ON u.registration_ip_address = upi.ip
WHERE upi.user_count > 1
ORDER BY upi.last_create DESC
6 个赞

Thanks, it works perfectly! What i need to change if i want to get the last used IPs instead of the ones used at registration?

1 个赞

ip_address instead of registration_ip_address.

4 个赞

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.