Always finding answers here so finally posting a question!
I have a MySQL query and I am trying to get a max count to help replicate an Access Pivot table.
Query:[code=mysql]
SELECT DISTINCT oTech, Count(sysID) as totRows
FROM view_schedule where SchedDate > '2007-08-01'
GROUP BY oTech, SchedDate
ORDER BY oTech ASC, totRows DESC;[/code]
Returns a table like this:
oTech.......... .......totRows
4.............. ............... .7
4.............. ............... .3
4.............. ............... .1
6.............. ............... .2
6.............. ............... .1
7.............. ............... .1
9.............. ............... .2
Problem:
I only need the top row for each different oTech. I can skip other rows in my PHP code but was curious if there was a way to just get the maximum count for each oTech...
I have a MySQL query and I am trying to get a max count to help replicate an Access Pivot table.
Query:[code=mysql]
SELECT DISTINCT oTech, Count(sysID) as totRows
FROM view_schedule where SchedDate > '2007-08-01'
GROUP BY oTech, SchedDate
ORDER BY oTech ASC, totRows DESC;[/code]
Returns a table like this:
oTech.......... .......totRows
4.............. ............... .7
4.............. ............... .3
4.............. ............... .1
6.............. ............... .2
6.............. ............... .1
7.............. ............... .1
9.............. ............... .2
Problem:
I only need the top row for each different oTech. I can skip other rows in my PHP code but was curious if there was a way to just get the maximum count for each oTech...
Comment