如何计算唯一值?


9

我正在尝试获取唯一的ip_addresses的数量(在这种情况下为'3')。该表如下所示:

结构体:

CREATE TABLE bandits (
  key text NOT NULL,
  ip_address inet,
  offence text,
  count bigint DEFAULT 1);

数据:

从stdin复制盗贼(密钥,ip_address,犯罪,计数);
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

1
试试select distinct .....
John Gardeniers

Answers:



By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.