Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying get the number of unique ip_addresses (in this case '3'). The table looks like this:

Structure:

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

Data:

COPY bandits (key, ip_address, offence, count) FROM stdin;
127.0.0.1_testing   127.0.0.1  testing  1
127.0.0.2_testing   127.0.0.2  testing  3
127.0.0.2_testing2  127.0.0.2  testing2 1
127.0.0.3_testing   127.0.0.3  testing  1
share|improve this question
1  
Try select distinct ..... –  John Gardeniers Feb 15 '11 at 1:50

1 Answer 1

up vote 4 down vote accepted
SELECT COUNT(DISTINCT ip_address) FROM bandits
share|improve this answer
    
wow, thank you, I was trying SELECT DISTINCT COUNT[...] etc. Sometimes I'm just unseeing... –  Tie-fighter Feb 15 '11 at 2:07

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.