create table mintst (n int not null default 0); select min(n),max(n) from mintst; a) 0, 0 b) 0, 255 c) NULL, NULL d) 0, NULL
[ SQL Expressions (15%) - NULL Values ]
mysql 5.0/5.1 questions for learning purposes
create table mintst (n int not null default 0); select min(n),max(n) from mintst; a) 0, 0 b) 0, 255 c) NULL, NULL d) 0, NULL
[ SQL Expressions (15%) - NULL Values ]
You must be logged in to post a comment.
Answer:
c
The MIN/MAX values for an empty table are undefined and therefore NULL. I’ve seen statistics and reporting software abort because of empty tables ;-) You can use
COALESCE()
orIFNULL()
to catch thoseNULL
-values.mysql> select min(n),max(n) from mintst;
+--------+--------+
| min(n) | max(n) |
+--------+--------+
| NULL | NULL |
+--------+--------+
1 row in set (0.00 sec)