sqlserver语句做数值大小比较的实现

上传人:xiao****1972 文档编号:84087436 上传时间:2019-03-02 格式:DOC 页数:2 大小:12KB
返回 下载 相关 举报
sqlserver语句做数值大小比较的实现_第1页
第1页 / 共2页
sqlserver语句做数值大小比较的实现_第2页
第2页 / 共2页
亲,该文档总共2页,全部预览完了,如果喜欢就下载吧!
资源描述

《sqlserver语句做数值大小比较的实现》由会员分享,可在线阅读,更多相关《sqlserver语句做数值大小比较的实现(2页珍藏版)》请在金锄头文库上搜索。

1、SQLServer语句做数值大小比较的实现问:sql server里我有、二张表:表有一个字段。通过条件查询出来其中一个字段的返回值。表有二个字段。通过条件查询出来其中2个字段的返回值,并将其值相加。然后把、表的返回值做数字的大小比较。如果返回表的值大于表的值,则返回“错误”的提示。反之,则报正常。怎么写这个sql语句?答:create table t1(idd varchar(10) not null,value int not null)create table t2(idd varchar(10) not null,value1 int not null,value2 int not n

2、ull)insert into t1select 1, 10union allselect 2, 20insert into t2select 1, 3, 5union allselect 2, 12, 9declare Res varchar(10)select Res = case when (select t1.value from t1 where idd=2) (select value=t2.value1+t2.value2 from t2 where idd=2) )then 错误 else 正确 endselect Resdrop table t1drop table t2/*结果正确*/

展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 大杂烩/其它

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号