sql - MySQL MAX from count query -



sql - MySQL MAX from count query -

i have table rozpis_riesitelov contains columns : id_rozpisu_riesit, id_zam, id_projektu, id_ulohy.

i made query :

select id_zam, id_ulohy, count(*) counted rozpis_riesitelov grouping id_zam having id_ulohy in (1,2,8)

which shows me id of employee (id_zam) , how many times in project (id_ulohy irrevelant had select beacuse of having clause). shows me in db looking employee id of 4 in 6 projects (yes, order want see max). when max of query this:

select max(counted) (select id_zam, id_ulohy, count(id_zam) counted rozpis_riesitelov grouping id_zam having id_ulohy in (1,2,8)) riesitel

which shows me number 149 instead of 6.

so need find employee occurs in of projects.

what's wrong sorting count() value, , limiting 1 result?

select `id_zam`, `id_ulohy`, count(*) `counted` `rozpis_riesitelov ` `id_ulohy` in ( 1, 2, 8 ) grouping `id_zam` order `counted` desc limit 1

mysql sql

Comments

Popular posts from this blog

xslt - DocBook 5 to PDF transform failing with error: "fo:flow" is missing child elements. Required content model: marker* -

mediawiki - How do I insert tables inside infoboxes on Wikia pages? -

Local Service User Logged into Windows -