sql improovements
sql improovements