Creating thirdrule SQLQuery