All pastes #718505 Raw Edit

Stuff

public text v1 · immutable
#718505 ·published 2007-09-28 13:56 UTC
rendered paste body
SELECT COUNT( DISTINCT fault.faultref ) AS c, users.id, users.name
FROM users, fault
WHERE users.teamid =1
AND (
users.id = fault.ownerid
OR (

SELECT COUNT( DISTINCT fault.faultref
FROM fault
WHERE fault.ownerid = users.id
AND lastclosed IS NULL
AND resolved IS NULL ) =0
)
AND users.id !=1
AND users.holiday IS NULL
AND fault.resolved IS NULL
AND fault.lastclosed IS NULL
GROUP BY users.id
ORDER BY c