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
 MAX(SELECT...)

Author  Topic 

klau962
Starting Member

8 Posts

Posted - 2009-08-05 : 17:14:39
I want to do something along the lines of

SELECT
MAX(SELECT
CASE loccvg.DEDUCTAMT
WHEN > 1 THEN loccvg.DEDUCTAMT
ELSE loccvg.DEDUCTAMT*loccvg.VALUEAMT
END "newDeductible")

FROM
loccvg

WHERE
loccvg.DEDUCTAMT > 0

But this doesn't work... any ideas?
Thanks in advance!
:)

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-08-05 : 17:19:44
[code]select max(newDeductible) as newDeductible from
(
SELECT
CASE loccvg.DEDUCTAMT
WHEN > 1 THEN loccvg.DEDUCTAMT
ELSE loccvg.DEDUCTAMT*loccvg.VALUEAMT
END "newDeductible"
FROM loccvg
WHERE loccvg.DEDUCTAMT > 0
)dt[/code]


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

klau962
Starting Member

8 Posts

Posted - 2009-08-05 : 17:45:59
Thanks for this...

When I run this I get the message:
Incorrect syntax near '>'

what does this message mean?
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-08-05 : 18:02:17
Small typo.. :)
quote:
Originally posted by webfred

select max(newDeductible) as newDeductible from
(
SELECT
CASE WHEN loccvg.DEDUCTAMT
WHEN > 1 THEN loccvg.DEDUCTAMT
ELSE loccvg.DEDUCTAMT*loccvg.VALUEAMT
END "newDeductible"
FROM loccvg
WHERE loccvg.DEDUCTAMT > 0
)dt



No, you're never too old to Yak'n'Roll if you're too young to die.

Go to Top of Page
   

- Advertisement -