Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Where when if then syntax confusion

Author  Topic 

ConradK
Posting Yak Master

140 Posts

Posted - 2009-12-02 : 14:15:12
I am very new to this stuff, and am lost of conditional statments.

Where is my syntax wrong

where pe.Book_ISBN is null and pe.SalePrice is null then pe.productprice else if pe.book_isbn is null then pe.SalePrice else pe.book_isbn end as "ItemPrice"

this makes sense in my head... what am i doing wrong?

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-02 : 14:26:13
Is this in a SELECT?

maybe this?

case when pe.Book_ISBN is null and pe.SalePrice is null 
then pe.productprice
else case when pe.book_isbn is null
then pe.SalePrice
else pe.book_isbn end
end as "ItemPrice"
Go to Top of Page

ConradK
Posting Yak Master

140 Posts

Posted - 2009-12-02 : 14:29:24
bingo. That solved it. Your structure is very similar to my original structure, justy more 'end' statements.

and it was a SELECT.

Thanks alot!!!!!!!!!!!!!!
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-12-02 : 14:54:28
You are welcome!
Go to Top of Page
   

- Advertisement -