Subscribe to this thread
Home - General / All posts - Min - Max in SQL
Corentin85 post(s)
#31-Jul-20 23:12


I want to compute a new Field A which would be the minimum of 2 existing fields B and C, I was expecting to do

Select min([B],[C]as [A] from Table

But this doesn't work since the word 'min' is an agregate function which intends to returns the min of a specific field...

So I did this workaround but it is not very elegant...

select (case when [A]<[B] then [A] else [B] endfrom Table

Is there a better way to do so?


475 post(s)
#01-Aug-20 08:39


SELECT INLINE Max([pop2010], [pop2012], [pop2016], [pop2018]) FROM [States];

Corentin85 post(s)
#03-Aug-20 14:38

Worked perfectly thank you very much!

Manifold User Community Use Agreement Copyright (C) 2007-2019 Manifold Software Limited. All rights reserved.