Fixed sql query where notes were not showing properly