I don't see an if statement in the query - did you mean the case expression perhaps? What should the result look like? Here is one way of counting, if you are looking for counts grouped by lastname and firstname. Take a look at this, and if this is not what you are looking for, can you post a sample of the expected output data?SELECT lastname, firstname, SUM(CASE WHEN 'OTP' = 'Late' THEN 1 ELSE 0 END) AS LateCount, SUM(CASE WHEN 'OTP' = 'Early' THEN 1 ELSE 0 END) AS EarlyCount, SUM(CASE WHEN 'OTP' = 'On-Time' THEN 1 ELSE 0 END) AS OnTimeCountFROM(SELECT b.ldate, c.lastname, c.firstname, ((e.schtime/60)/60) as "Hour", e.schtime, e.actualarrivetime, ((e.actualarrivetime-e.schtime)/60) as "Min Past", case when ((e.actualarrivetime-e.schtime)/60) > 30 then 'Late' when ((e.actualarrivetime-e.schtime)/60) < 0 then 'Early' else 'On-Time' end 'OTP', b.SubTypeAbbr, e.schedstatus, es.evstrname FROM clients c, booking b, bookinglegs bl, events e, eventstrings es WHERE e.schedstatus in (1, 2, 3, 4, 20, 21) AND c.clientid = b.clientid AND b.bookingid = bl.bookingid AND bl.legid = e.legid AND e.evstrid=es.evstrid AND e.schid=es.schid AND e.schid>=? AND e.schid<=?AND e.schtime > 0 AND e.esttime > 0 ) sGROUP BY lastname, firstname