易截截图软件、单文件、免安装、纯绿色、仅160KB

求一SQL语句 - MS-SQL Server / 应用实例

数据库表A
ID Weight VolWeight
1 10 6
2 5 8
3 1 3
4 12 7
5 11 2
6 3 5

需要得到如下表内容,要怎样实现
ID OUTWeight 
1 10
2 8
3 3
4 12
5 11
6 5



SQL code:
select id, case when weight>volweight then weight else volweight end OUTweight
from [Table]


SQL code:
select id , OUTWeight = (case when Weight > VolWeight then Weight else VolWeight end ) from a


引用
SQL code
select id, case when weight>volweight then weight else volweight end OUTweight
from [Table]

up

SQL code:
create table a (ID int,Weight int,VolWeight int)
insert into a values(1 ,10, 6)
insert into a values(2 ,5 ,8)
insert into a values(3 ,1 ,3)
insert into a values(4 ,12, 7)
insert into a values(5 ,11, 2)
insert into a values(6 ,3 ,5)
go

--1
select id , OUTWeight = (case when Weight > VolWeight then Weight else VolWeight end ) from a

--2
select id


相关问答:

jsp链接sql2000的疑问?



type Exception report


message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

org.apache.jas ......

SQL如何优化问题 - MS-SQL Server / 疑难问题

今天做了一个存储过程   环境是SQL2000数据库  
大致如下
建立临时表
定义员工游标
        循环员工(属于1个公司)  
        ......

MS SQL作业问题 - MS-SQL Server / 应用实例

如何在SQL2005中设定定时作业,比如说定时清理某些表的数据,
或者是定时的将某些表的数据导出excel!
在线等待,急急急,最好是详细步骤!
之前我做的作业有点问题!
帮UP

参考:http://hi.baidu.com/toiota ......

请教SQL语句查询问题? - MS-SQL Server / 基础类

我想查询出每天数据的最大的一个值。表的格式如下
表名: hisdata
字段 编号 值 状态 时间  
  Id value state dattime  
  101 32.3 0 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号