Sql queries

A lot of errors still.