Fixed external aspect sql query