Re: SET value based on a condition On Mar 20, 11:38 am, worldcycl...@gmail.com wrote:
> I have a table with two columns, "expired" and "date"
> The data is like this...
>
> SELECT expired, date FROM table
> expired date
> NO 01-01-2001
> NO 01-01-2001
>
> What I need to do is return an Expired value of "YES" if the date is
> older than NOW().
>
> I started messing around with If statements and have figured out how
> to set a default in the same column that is being checked but am
> stumped on this one. What I need, based on the above data is ...
>
> SELECT expired, date FROM table
> expired date
> YES 01-01-2001
> YES 01-01-2001
>
> Any suggestions and I thank you profusely in advance.
> JC
select (case when date < now() then 'YES' else expired end) expired,
date
from table |