add sql queries

and small fix