4个答案 按时间排序 按投票排序
-
isnull函数防止查询结果为空,防止接下来需要这个值时可能造成空指针异常(Java.lang.NullPointerException)
2011年3月16日 16:39
-
max是去最大值的函数;
isnull是判断是否为空,两个参数:一个是要进行判断的,另一个是如果判断为真返回的值。
select isnull(max(字段1+1),1) from table;
不知道你是查字段叫“字段1+1”呢,还是查第一个字段的最大值再加上1然后在判断呢?
表是这样的?
字段1 字段2 字段32011年3月16日 16:37
-
里面包含了两个sql函数:isnull和max
ISNULL 语法:
ISNULL ( check_expression , replacement_value )
参数 check_expression 将被检查是否为 NULL,如果为NULL,值将有replacement_value 替代。
MAX函数是取字段中的最大值。
select isnull(max(字段1+1),1) from table意思为:
从table中查询“字段1+1”的最大值,如果“字段1+1”的最大值为null,则值取1,否则取“字段1+1”的最大值。2011年3月16日 16:26
相关推荐
set @sql=’select top’+str(@end-@start+1)+’+from T where rid not in(select top’+str(@str-1)+’Rid from T where Rid>-1)’ exec sp_executesql @sql 注意:在top后不能直接跟一个变量,所以在实际应用中...
set @sql=’select top’+str(@end-@start+1)+’+from T where rid not in(select top’+str(@str-1)+’Rid from T where Rid>-1)’ exec sp_executesql @sql 注意:在top后不能直接跟一个变量,所以在实际应用...
set @sql=’select top’+str(@end-@start+1)+’+from T where rid not in(select top’+str(@str-1)+’Rid from T where Rid>-1)’ exec sp_executesql @sql 注意:在top后不能直接跟一个变量,所以在实际应用中...
SQL>select table_name,cache from user_tables where instr(cache,'Y')>0; 3、索引 查看索引个数和类别 SQL>select index_name,index_type,table_name from user_indexes order by table_name; 查看索引被...
16、select ename, sal, comm from emp where comm is not null; --(选择comm字段不为null的数据) 17、select ename, sal, comm from emp where sal in (800, 1500,2000); --(in 表范围) 18、select ename, sal...
MySQL中外键的table的外键引用列可以插入数据可以为null,不参照主表的数据。 使用子查询插入数据 insert into temp(name) select name from classes; 多行插入 insert into temp values(null, ‘jack’, 22), ...
命令: select <字段1,字段2,...> from 表名 > where 表达式 > 例如:查看表 MyClass 中所有数据 mysql> select * from MyClass; 2)、查询前几行数据 例如:查看表 MyClass 中前2行数据 mysql> select * from ...
SQL>select table_name,cache from user_tables where instr(cache,'Y')>0; 3、索引 查看索引个数和类别 SQL>select index_name,index_type,table_name from user_indexes order by table_name; 查看索引被...
(select max(rowid) from a b where a.aa=b.aa); 13、删除同其他表相同的行 delete from a where exits (select \'X\' from b where b.no=a.no); 或 delete from a where no in (select no from b); 14、查询...
二进制数据类型 row 1~2000字节 可变长二进制数据,在具体定义字段的时候必须指明最大长度n long raw 1~2GB 可变长二进制数据 LOB数据类型 clob 1~4GB 只能存储字符数据 nclob 1~4GB 保存本地语言字符集数据 blob...
Sql Server实用操作小技巧集合 包括安装时提示有挂起的操作、收缩数据库、压缩数据库、转移数据库给新用户以已存在用户权限、检查备份集、修复数据库等 (一)挂起操作 在安装Sql或sp补丁的时候... set @i=@i+1 end
命令:select <字段,字段,...> from 表名 > where 表达式 > 例如:查看表 MyClass 中所有数据 mysql> select * from MyClass; 2)、查询前几行数据 例如:查看表 MyClass 中前行数据 mysql> select * from ...
1、用法:SELECT columns,prod2,prod3<列> FROM Table1,table2<表名> 分号结束 如: select id from s_emp; select last_name,name from s_emp,s_dept where s_emp.dept_id=s_dept.id;--列表每人所在部门 SELECT...
SELECT * FROM Type WHERE T_ID=100 AND T_NAME=’FRUIT’ C. UPDATE SET T_ID=100 FROM Types WHERE T_Name=’FRUIT’ D. DELET * FROM Types WHERE T_ID=100 AND T_Name=’FRUIT’ 13. 用_____语句修改表的一行或...
select decode(x,1,'x is 1', 2 , 'x is 2','others') from dual 1.8.3.2 说明 当x等于1时,则返回‘x is 1’,当x等于2时,则返回‘x is 2’,否则,返回‘others’。 1.8.4 nulls first(nulls last)排序 1.8.4.1...
Select * from stu where address is null; e、优先级 小括号,not ,比较运算符 ,逻辑运算符,and比or优先级高,如果同时使用,建议使用(); 4、聚合 为了快速得到统计的数据,提供了5个聚合函数 Select 函数...
IS NULL关键字可以用来判断字段的值是否为空值(NULL)。如果字段的值是空值,则满足查询条件,该记录将被查询出来。如果字段的值不是空值,则不满足查询条件。其语法规则如下: IS [ NOT ] NULL 其中,“NOT”是可...
答:Select ID FROM table1 Where LastUpdateDate = (Select MAX(LastUpdateDate) FROM table1) 29.根据线程安全的相关知识,分析以下代码,当调用test方法时i>10时是否会引起死锁?并简要说明理由。 public void ...
IF ISNULL(@SearchKeyword,'') !='' OR RTRIM(@SearchKeyword)!='' BEGIN SET @TableViewQueryName = ' SELECT '+ ' ROW_NUMBER() OVER (ORDER BY RANK DESC) AS SerialNumber ,'+ ' F.[rank], '+ ' p.*' + ' ...
= 不等于 <=> NULL安全的等于(NULL-safe) ⼩于 > ⼤于 ⼩于等于 >= ⼤于等于 BETWEEN 存在与指定范围 IN 存在于指点集合 IS NULL 为NULL IS NOT NULL 不为NULL LIKE 通配符匹配 REGEXP或者RLIKE 正则表达式匹配 %...