On Fri, 25 Jan 2019 23:35:51 +0100
Cecil Westerhof <cldwester...@gmail.com> wrote:

> SELECT MIN(totalUsed)                  AS minimum
> ,      MAX(totalUsed)                  AS maximum
> ,      MAX(totalUsed) - MIN(totalUsed) AS range
> FROM   quotes
> 
> But I did not like it because I repeated the MIN and MAX. 

There's no problem with either version.  For what it's worth, I like
your first one, above.  It's shorter, and the meaning is not obscured
by calling min & max twice.  Computationally they should be the same;
the DBMS will traverse "quotes" just once.  

If the repeated calcuations were more complicated, to the point that
burying them in a subquery made the whole thing shorter, then I would
probably opt for something like the 2nd version,  to avoid the
possibility of errors in the repeated code. 

--jkl
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to