adding query 2, dont know how it works yet because dont have our db with create temp table privileges