added query creating temporary table, inserting data and then querying table