简体   繁体   中英

MySQL - SELECT Count DISTINCT

I have a "work" table with the following fields:

  • work_id
  • work_pop_id
  • work_log
  • work_lock

I would like to display for each DISTINCT "work_pop_id" the number of records in the table.

Thank you

select count(work_id)
from work
group by work_pop_id

Try this:

select work_pop_id, count(work_id) as work_prop_count
from `work`
group by work_pop_id 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM