1

I have table like:

ID PERSON UPDATE
1   132  1.1.2015
1   132  2.1.2015
3   152  4.5.2013
9   152  1.2.2013

I need to count persons which have different id's which is greater than 1.

4
  • 1
    What are the results you want to get? What have you tried? Commented Jan 20, 2017 at 13:10
  • Result of upper table to be: 152 2 Commented Jan 20, 2017 at 13:13
  • If this table had a row 9 152 1.2.2014, would the result still be 2 or would it be 3? Commented Jan 20, 2017 at 13:26
  • result would be still 2 Commented Jan 20, 2017 at 13:40

2 Answers 2

1

I think you want this:

select person, count(distinct id)
from t
group by person
having count(distinct id) > 1;
Sign up to request clarification or add additional context in comments.

2 Comments

Needs to filter out id = 1.
@jpmc26 . . . Although perhaps not immediately obvious, the OP is trying to say "I need to count persons that have different ids".
0
select person, count(*) from table
where id>1
group by person

or

select person, count(*) from table
where id<>1
group by person

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.