Another useful SQL snippet to post today, used to identify machines where commands are stuck executing. This usually is an indication of a problem with the LabTech service on the machine, but could also mean something more underlying is broken on the client.

SELECT commands.computerid,
Count(*) AS NumOfCommands
FROM   commands
LEFT JOIN v_computers
ON commands.computerid = v_computers.computerid
WHERE  status = 2
GROUP  BY computerid
ORDER  BY numofcommands DESC