That sounds good. I'd love comments in the code though, explaining what each piece of the SQL is doing, for future readers/maintainers ;)