sql常用判断语句
2012-02-22 13:43
225 查看
sql常用判断语句
1:case when then else end示例一
SELECT 学号, 姓名,
等级=
CASE
WHEN 总学分 IS NULL THEN ‘尚未选课’
WHEN 总学分 < 50 THEN ‘不及格’
WHEN 总学分 >=50 and 总学分<=52 THEN ‘合格’
ELSE ‘优秀’
END FROM XS WHERE 专业名=’计算机’
示例二
update employee
set e_wage =
case
when job_level = ’1’ then e_wage*1.08
when job_level = ’2’ then e_wage*1.07
when job_level = ’3’ then e_wage*1.06
else e_wage*1.05
end
示例三
select a, (case a when 1 then '中' else '国' end) AS B from table1
2:isnull()
isnull(sum(incount),0)
3:存储过程中执行存储过程
a:直接执行存储过程
Exec [sp_OrderGetSendFee] @Cart_ID, 0, @User_ID, @tTotalPrice, @tSendFee, @tSendFee OutPut
b:执行sql字符串
Set @Str = 'Select @All = Count(*) From ('+ @SQL + ') t'
Exec sp_ExecuteSQL @Str, N'@All Int OutPut', @TotalRecord OutPut
4:执行拼凑sql 语句
Exec sp_ExecuteSQL @Str
相关文章推荐
- 常用判断重复记录的SQL语句
- sql常用判断语句
- SQL语句 常用条件判断
- SQL 常用判断语句
- sql常用判断语句
- SQL常用判断语句
- pl/sql常用判断语句
- SQL 常用判断语句
- sql常用判断语句
- SQL查询时常用,但不熟悉的相关语句-----邮标,行号,临时表,类型转换,字符串函数,sql 判断语句,检查是不是数字,变量,sql split 函数
- SQL常用判断检测语句
- 转自【柳永法】SQL统计:从北京到天津的与从天津到北京的汇总到一起 常用sql语句 SQL Server 生成版权信息及测试环境信息
- 学习资料 50个常用的sql语句
- mysql用户管理 ,常用sql语句 ,mysql数据库备份恢复
- mybatis中sql语句参数添加判断
- 常用sql语句-查询
- ibatis常用16条SQL语句
- 数据库管理员常用的 sql 语句 (查杀进程、连接数、死锁)
- 常用sql语句整理
- sql语句判断两个时间段是否有交集