Thanks Paul - much simpler.

I'd forgotton the CASE statement :(

Stephen

-----Original Message-----
From: Paul Ritchie [mailto:[EMAIL PROTECTED]]
Sent: Friday, 10 August 2001 11:22 a.m.
To: Multiple recipients of list offtopic
Subject: RE: [DUG-OFFTOPIC]: SQL question - return largest value in a
row



How about:
SELECT a, CASE WHEN b<c THEN c ELSE b FROM xx


Paul 

> -----Original Message-----
> From: Stephen Bertram [mailto:[EMAIL PROTECTED]]
> Sent: Friday, August 10, 2001 11:33 AM
> To: Multiple recipients of list offtopic
> Subject: RE: [DUG-OFFTOPIC]: SQL question - return largest value in a
> row
> 
> 
> After discussion here we've come up with :
> 
> SELECT a, ((SIGN(b-c)+1)*b + (SIGN(c-b)+1)*c)/2 FROM xx
> 
> Anyone got anything simpler ??
> 
> Stephen 
> 
> 
> >Hi All
> 
> >This should be simple, but I have a mental block ATM.  I'm 
> using MSS SQL 7.
> 
> >With a table : CREATE TABLE xx ( a int, b int, c int )
> >I want to run: SELECT a, fn(b, c) FROM xx
> >where fn(b,c) returns the larger of the values in columns b and c.
> 
> >How do I write the select?
> 
> >TIA 
> 
> >Stephen
> --------------------------------------------------------------
> -------------
>   New Zealand Delphi Users group - Offtopic List - 
> [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED] 
> with body of "unsubscribe offtopic"
> Web Archive at: http://www.mail-archive.com/offtopic%40delphi.org.nz/
> 
---------------------------------------------------------------------------
  New Zealand Delphi Users group - Offtopic List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe offtopic"
Web Archive at: http://www.mail-archive.com/offtopic%40delphi.org.nz/
---------------------------------------------------------------------------
  New Zealand Delphi Users group - Offtopic List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe offtopic"
Web Archive at: http://www.mail-archive.com/offtopic%40delphi.org.nz/

Reply via email to