fix a bug in sql of getting notes