问题:
数据库表test 只有一个属性num test{num}
求num的最大值(不能用Max)
解答
1 select ta.num,tb.num from test as ta ,test as tb where ta.num
得到的结果是 两个两列的结果集 ,第一列小于第二列
除了最大的数外,其他的数都会出现在第一列中
2 select tc.num from test as tc where tc.num not in
(select ta.num from test as ta ,test as tb where ta.num
从test表中找到num不在1结果集中的那一项,这一项的num属性就是表中num的最大值
///补充一个其他的小问题///
select * from table where column = null;//该写法错误
这个语句本意是想找出column列为null的所有项
但是问题是column=null不能判断出其是否等于null(即使column就是null) column=null返回的很可能是unknown值
所以正确的写法是
select * from table where column is null;
select * from table where column is not null;