We help IT Professionals succeed at work.

Sql syntax

red_75116
red_75116 asked
on
Medium Priority
165 Views
Last Modified: 2012-05-06
I need to modify a sql query and I need some help.  Here is the original case statement that works.

case
when (biddate > saledate) or saledate is null then biddate
when biddate <= saledate then saledate
else 0
end as anchordt,

However, I need to add this if/then clause or something.  When bidstatus='Y' then I the anchotdt to be getdate().  I cannot get it working.  I always get null values.  Biddate should be null when Bidstatus is "y" and I don't know if that is messing it up or not.
Comment
Watch Question

Commented:
Like this?

case
when bidstatus = 'Y' or biddate is null then getdate()
when (biddate > saledate) or saledate is null then biddate
when biddate <= saledate then saledate
else 0
end as anchordt,

By the way this question is incorrectly posted in the wrong zone..

Not the solution you were looking for? Getting a personalized solution is easy.

Ask the Experts

Author

Commented:
thanks!  I discovered it already, but that is exactly what I entered.  Sorry about the zone
Access more of Experts Exchange with a free account
Thanks for using Experts Exchange.

Create a free account to continue.

Limited access with a free account allows you to:

  • View three pieces of content (articles, solutions, posts, and videos)
  • Ask the experts questions (counted toward content limit)
  • Customize your dashboard and profile

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.