[BUGFIX] bug fix on sql