0

I have working in database Postgresql for the first time. I need your help to finding out a solution. One table contains 15 rows With a regn_srno as P.K., another table has the same regn_srno as F.K. I want to count the total number of rows which has the same regn_srno. But My problem is the second table has contain 2 or 3 fields with the same regn_srno. So when i use count in the query it shows 12 (including the same regn_srno), but the original number is 10. Due to the same regn_srno repeat in the second table i got the answer as 12. When we group by regn_srno we get the result as 1,1,1,1,2,1,2,1,1,1. So i need the query to get the count as 10.Please help me. Please send me the answer through my mail id.

1
  • Adding the schemas of your tables (and perhaps your queries) COULD help to explain your problem. Commented Dec 19, 2009 at 11:28

2 Answers 2

1

For what I could figure out without tables schema, I think you want

SELECT count(DISTINCT regn_smo) FROM t1 JOIN t2 USING (regn_smo);
Sign up to request clarification or add additional context in comments.

Comments

0

You could simply do:

SELECT count(DISTINCT regn_smo) FROM t2

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.