So to keep it simple, I’m working on a problem that requires a simple case of utilizing the WHERE clause to bring back records that have the field (we’ll call it ‘tax’) equal to $0.00
So as per usual, I thought I could do:
WHERE tax = 0;
But I keep getting an error. And I’m pretty sure it’s because of this weird MONEY data type. Now, just to be clear, I can’t convert or change the datatype. I’m just looking for how I should be formatting that WHERE clause to make it grab those values in a data type like that. I’ve tried WHERE tax = 0.00, WHERE tax = $0.00, etc. etc..
Thanks in advance
Advertisement
Answer
You need to cast the value to money:
where tax = 0::money
or cast the money type to numeric:
where tax::numeric = 1.23
or use a string value:
where tax = '0'
But you should really try to convert that column to a different type