reading sql file using min/max queries and sort criteria