Tags
Asked 5 years ago
2 Oct 2019
Views 703
kord

kord posted

how to put counted value in query in where condition in Mysql query ?

finding duplicate entry for particular date so i use following code



select `date`, count(*) as employe_count from  where   group by eid , `date`

i am getting employecount is 1 or 2 or 3 but i only need entry which have employe_count more than 1
so i put following query

select `date`, count(*) as employe_count from  where   employe_count>1 group by eid , `date`


and i getting following error

 
#1054 - Unknown column 'employe_count' in 'where clause'
Mitul Dabhi

Mitul Dabhi
answered Nov 30 '-1 00:00

Use HAVING clause

like

select `date`, count(*) as employe_count from  employee group by eid , `date`  having employe_count>1 



Note : HAVING clause after the FROM, WHERE, SELECT and GROUP BY clauses and before ORDER BY, and LIMIT clauses.

Post Answer