|
Posted by Andy Hassall on 10/14/81 11:26
On Mon, 12 Sep 2005 11:50:52 +0300, "Kimmo Laine"
<eternal.erectionN05P@Mgmail.com> wrote:
>I want
>to use if-statement inside a query. I remember clearly that something like
>this would actually work in MySQL, but so far I haven't got it working in
>MSSQL.
>
>Trying something like
>"SELECT IF(dsum > 100, 100, dsum) as dsum_2 from view1"
The Standard (with a capital 'S', i.e. SQL92) statement is CASE.
SELECT CASE
WHEN dsum > 100 THEN 100
ELSE dsum
END dsum_2
from view1
If this doesn't work, ask in an MSSQL group.
--
Andy Hassall :: andy@andyh.co.uk :: http://www.andyh.co.uk
http://www.andyhsoftware.co.uk/space :: disk and FTP usage analysis tool
[Back to original message]
|