1

i have a table like :

id_cat  id_city 
1   33
1   33
1   33
2   44
2   33
2   55

and i want to obtain a result like :

id_cat id_city cat_count 
1      33      3  
2      44      1
2      33      1
2      55      1 

how can i build my query ? Thanks!

1 Answer 1

2

Use COUNT() which is an aggregate function and a GROUP BY clause.

SELECT  id_cat, id_city, COUNT(*) cat_Count
FROM    tableName 
GROUP   BY id_cat, id_city
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.