M
M
Mykola2018-03-12 18:28:23
MySQL
Mykola, 2018-03-12 18:28:23

Why does the query return count(*) = 3?

SELECT 
  `poll_id`, 
  `user_id`, 
  COUNT(*) as polls_count 
FROM 
  `rel_poll_question_user` 
WHERE 
  (
    `rel_poll_question_user`.`department_type` = 'ask-payroll'
  ) 
GROUP BY 
  `poll_id`, 
  `user_id`

Data:
prntscr.com/iq6079

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Max Payne, 2018-03-12
@YardalGedal

Because there are three elements.

M
Mikola, 2018-03-12
@iSensetivity

So shouldn't it be 1? Because GROUP BY `poll_id`, `user_id` is 1.

K
kisaa, 2018-03-13
@kisaa

Read about DISTINCT.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question