Aggregate functions on empty sets in SQL
From: Mikito Harakiri <nospam_at_newsranger.com>
Date: Tue, 06 Nov 2001 18:02:17 GMT
Message-ID: <JAVF7.14841$xS6.20943_at_www.newsranger.com>
The query
Date: Tue, 06 Nov 2001 18:02:17 GMT
Message-ID: <JAVF7.14841$xS6.20943_at_www.newsranger.com>
The query
SQL> select min(1) from tbl where 1=0;
MIN(1)
returns one row with NULL. 2 questions:
- Is it SQL standard?
- Is it for any reason better than retuning minimal number in the numeric domain? (Same for dates, strings and other domains with total ordering). Every aggregate function internally starts a loop with some value (for example, sum starts with 0), and that value is the intuitive result of quering the empty set. Besiades, in order to find out the min/max numbers in the domain I would have to make one less trip to the documnetation;-)