0

I have these two tables:

type

TYPE_ID           TYPE
   1              Type1   
   2              Type2   
   3              Type3   
   4              Type4   

user_type

USRTYPE_ID        TYPE_ID
    1               1
    2               1  
    3               2 
    4               4

What I need to do is count how many types are there in user_type table. For e.g.

SELECT QUERY returns:

 TYPE            QUANTITY
 Type1               2
 Type2               1
 Type4               4
1
  • Hint join ,group by and count Commented May 7, 2014 at 20:42

1 Answer 1

1

This should work

select count(USRTYPE_ID) as QUANTITY, TYPE
from user_type
inner join type
on user_type.TYPE_ID = type.TYPE_ID
group by TYPE
Sign up to request clarification or add additional context in comments.

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.