Reply to Re: inline if

Your name:

Reply:


Posted by Erland Sommarskog on 09/21/05 16:14

Dima Gofman (dg@cfa-solutions.com) writes:
> I want to execute something like
>
> select iif(type='credit',amount*-1,amount) from table
>
> how can i do that? help file says iif is used in Multidimensional
> Expressions but that seems overly complicated for this task.

SELECT CASE type WHEN 'credit' THEN -1 ELSE 1 END * amount

See further the CASE expression in Books Online.


--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация