
Write a query against system objects using Count, Distinct, Null, Group by, and Case. Execute query to insert the results into a table. Comment code appropriately, use proper code formating, and consider the use of truncation, date stamps and indexes if applicable.