重複する IP を検索するクエリが必要

こんにちは。フォーラム、GitHub、Google を検索しましたが、重複する 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.