Little bit of spying

Maybe under slight influence of the latest James Bond movie, but more probably because I was asked for it, I provide you with SQL query to spy on your teachers. This asnwers a question which courses have a teacher (or teachers) and when was the first time and last time they visited their courses.
It could be used for 1.8+ version of Moodle, with default setting of roles (as roleid = 3 means "teacher" role).
I don't know about speed of this thing, so be careful of running this on production servers under heavy load. Use it lightly, no whipping of lazy teachers please :)

Btw I used Adminer, very lightweight MySql tool, for running this. This can come really handy, if you don't have anything stronger at hand.