我正在尝试获取唯一 ip_addresses 的数量(在本例中为“3”)。该表如下所示:
结构:
CREATE TABLE bandits (
key text NOT NULL,
ip_address inet,
offence text,
count bigint DEFAULT 1);
Run Code Online (Sandbox Code Playgroud)
数据:
从标准输入复制强盗(key、ip_address、offence、count); 127.0.0.1_testing 127.0.0.1 测试 1 127.0.0.2_testing 127.0.0.2 测试 3 127.0.0.2_testing2 127.0.0.2 testing2 1 127.0.0.3_testing 127.0.0.3 测试 1
Mar*_*son 15
SELECT COUNT(DISTINCT ip_address) FROM bandits
Run Code Online (Sandbox Code Playgroud)