I’m confused on why the following SQL sentence returns one row:
#MySQL
select max(1) from dual where 0 = 1
#SQLite
select max(1) where 0 = 1
I’m really confused about this result. Can anyone please shed some light over this behavior?
Thanks in advance!
An aggregate like
maxwithout agroup byalways returns one row. If the underlying rowset it empty, it will return a single row withnull. Otherwise, it returns the maximum of the column you specified.The
whereclause affects which rows the maximum is calculated for. It does not change the fact that the query has to return a maximum.