如下表1:
------------------------
编号 变形值1 102 -53 124 -6
--------------------------
我要取出最大的变形值和改值的编号,最大的变形值就是指绝对值最大的那个不能用abs,因为abs后都是正数了,我需要原始的值(当最大变形值为负的话)这个SQL该如何写???
------------------------
编号 变形值1 102 -53 124 -6
--------------------------
我要取出最大的变形值和改值的编号,最大的变形值就是指绝对值最大的那个不能用abs,因为abs后都是正数了,我需要原始的值(当最大变形值为负的话)这个SQL该如何写???
解决方案 »
- aspxgridview分页记录时间
- web程序如何访问局域网内计算机?
- pcAnywhere的用法问题,请教大家!
- datalist动态显示图片 没东西
- 为啥3个人同时访问就会出现数据库操作出错,如何解决多人访问优化问题
- JavaScript代码混淆器,有在线免费版
- 请问我这个程序员能值几个钱?大家评一下
- 请问这是什么错误啊??The compiler failed with error code 128.
- asp.net web向rdlc传参数
- 散分!顺便推荐个好的网站!!(早到早得哦!)
- C#在WEB程序中如何自动搜过出淘宝等网站上某商品的最低价格,用webBrowser,HttpWebRequest都遇到问题
- NHibernate 多表查询并显示在DataGrid 的问题
select * from users where PKID=(select max(PKID) from users)类比下你自己换列名期待高手更好的方法
select 编号,变形值 from 表名 where abs(变形值)=(select max(abs(变形值)) from 表明)
from 表1
where abs(变形值) = (
select max(abs(变形值)) from 表1 )
insert @t select 1,10
union all select 2,-5
union all select 3,12
union all select 4,-6--方法一
select *
from @t
where abs(变形值)=(select max(abs(变形值)) from @t)--方法二
select top 1 *
from @t
order by abs(变形值) desc/*
所影响的行数为 4 行)编号 变形值
----------- -----------
3 12(所影响的行数为 1 行)编号 变形值
----------- -----------
3 12(所影响的行数为 1 行)*/
还是10楼的XD写的有用
应该是这样
select a.编号,a.变形值 from 表1 a,(select 编号 from 表1 where abs(变形值)=(select max(abs(变形值)) from table2)) b where a.编号=b.编号
应该是差量最小的一个才对