编写了一个SQL语句,在执行过程中,发现这个SQL的MAX函数有些问题,情况如下:
select max(CONV(SUBSTRING(SIN_SERIAL,5),16,10 ) ) as serial FROM IN_TELE_150318 WHERE MID(SIN_SERIAL,4,1) = '1' ;
执行结果如下:
mysql> select max(CONV(SUBSTRING(SIN_SERIAL,5),16,10 ) ) as serial
FROM IN_TELE_150318 WHERE MID(SIN_SERIAL,4,1) = '1' ;
+--------+
| serial |
+--------+
| 99 |
+--------+
1 row in set
mysql>
然后去掉max 函数,执行如下:
select CONV(SUBSTRING(SIN_SERIAL,5),16,10 ) as serial
FROM IN_TELE_150318 WHERE MID(SIN_SERIAL,4,1) = '1'
。。。。。
| 117 |
| 118 |
| 119 |
+--------+
119 rows in set
总共119条记录,最大值也是119 ,但是用MAX函数取出来就是99
真想知道导致这个问题的原因是什么呀?
阅读(2562) | 评论(0) | 转发(0) |