select - MySql how to count rows in 1 command -


hey got table workers , number of department work @ , need show amount of departments , there way in 1 select command? been trying use count , group manage show either total amount of workers or total amount of workers per department. p.s explain alittle better simple version , got table

name / department   john     5 jerry    4 josh     4 erik     1 

in case need somehting : amount_of_departments 3

if use count() amount_of_departments ... group department 1 2 1 or if use count() amount_of_departments .... 4 if possible lacking basic sql knowledge since starter : x

you looking count(distinct):

select count(distinct department) table t; 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -