Home > OS >  Why is PostgreSQL picking up the wrong column data?
Why is PostgreSQL picking up the wrong column data?

Time:06-14

I'm doing this query and it's picking 'ar' 16, when I've specified to only get 'ar' equal to or less than 3?

SELECT ticket_id, status,targets, ar, create_date FROM tufin_sc_tickets WHERE create_date >= '2022-01-06' AND create_date <= '2022-14-06' AND targets <= '3' AND ar <= '3' AND (status = '0' OR status = '1' OR status = '2' OR status = '3' OR status = '4');

enter image description here

Any ideas why?

enter image description here

CodePudding user response:

I think it's because ar type is text. you have to cast it first. change

AND ar <= '3'

to

AND CAST (ar AS INTEGER) <= 3;
  • Related