Fix sql error
Merge pull request #2156 from elinw/sqlfixoct6

Fix sql error