SQL to generate tables and sample rows