Added sql conditional for pg