P
P
Pavel2020-04-24 12:17:31
MySQL
Pavel, 2020-04-24 12:17:31

Why does COUNT count only 1 user?

there is a base in it a list of users and a string value, I'm interested in these fields
user_id | contract_name
1 | ordinary
1 | strange
2 | ordinary
2 | strange

doing

SELECT user_id, dogovor_name, COUNT(*) AS cnt
                    FROM user_dolg
                    WHERE dogovor_name='обыкновенный'

but I get only the user with id 1 , and then it doesn't count, why?
How to count repetitions for each user?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
nozzy, 2020-04-24
@mrusklon

group by user_id

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question