Saurabh wagh
Saurabh wagh

Reputation: 61

Operator does not exist: character varying = record in Postgres

I am trying to execute query in community edition version of postgres:

select COUNT(*) 
from cdar_cpms_owner.hshldgrp_wkly_actvty 
where wkly_actvty_cd  IN (('B','H') ,'N')

From that query, I get this error:

ERROR: operator does not exist: character varying = record

LINE 1: ..._owner.hshldgrp_wkly_actvty where wkly_actvty_cd IN(('B','H... ^ HINT: No operator matches the given name and argument types. You might need to add explicit type casts.

While the same query is working fine with the EDB version of postgres.

Can anyone please suggest what changes are required in this query to make it work?

Upvotes: 2

Views: 7486

Answers (1)

GMB
GMB

Reputation: 222492

Here:

where wkly_actvty_cd IN ( ('B','H'),'N')

Your list has a nested list element: ('B','H'). So Postgres ends up trying to compare a scalar value (wkly_actvty_cd) to a tuple, which raises the error that you are getting.

Did you actually mean?

where wkly_actvty_cd IN ('B', 'H', 'N')

Upvotes: 0

Related Questions