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

mssql 求多字段最大值

//相关sql
SQL code:

create table tb1
(
tId int,
tName nvarchar(20),
class1 int,
class2 int
)
insert into tb1
select 1,'test',10,20
union all
select 1,'test1',20,35
union all
select 1,'test2',30,30
union all
select 2,'test21',30,85
union all
select 2,'test22',50,75
union all
select 3,'test31',60,65
union all
select 3,'test32',70,70



//单个字段的会,下面是求单个字段的
SQL code:

select a.* from tb1 a,(select tId,max(class1) as maxT from tb1 group by tId) b
where a.tId=b.tId and a.class1=b.maxT order by a.tId



//数据显示如下
SQL code:

tId tName class1 class2
1 test2 30 30
2 test22 50 75
3 test32 70 70



//我想显示为
SQL code:

tId tName maxClass
1 test2 35
2 test22 85
3 test32 70



我想要的结果就是class1,class2不区分,取最大值。

//谢谢。
SELECT TID,TNAME,MAX(CLASS1 )
from (
SELECT TID,TNAME,CLASS1 from TB
UNION


相关问答:

150分求vbscript中判断mssql语法错误

在vbscript中不用on error resume next如何判断mssql语法错误!
TRY CATCH?


或者使用流程控制语句
if 
else


不用on error 用那个我就不需要在这里寻找答案

引用
不用on error 用那个我就不需 ......

FCKeditor 更新数据库(mssql)的问题

用了FCKeditor的编辑器,存入普通文章后,可以更新。当存入word的那种表格格式的文章时候,就出现无法更新的问题。 <httpRuntime maxRequestLength="2097151" executionTimeout="43200"/&g ......

急求一MSSQL去除重复项语句


基础表A、B如图,由于一条新闻中可能有多张图片,所以B中会出现多个图片编号对一个新闻编号的情况。
求创建C表(视图)的sql语句。
SQL code:
select
b.pictureid as 图片编号,a.newstitle as 新闻标题,a.n ......

MSSQL有 类似于 SPLIT的函数吗?

如题- -~
我有这么个东西
一个
字符串如下所示
1,2,3,4,5
然后我
需要循环的把 这些数据插入到数据库中
我该怎么做?
http://blog.csdn.net/htl258/archive/2009/09/09/4533846.aspx


SQL code:
我现 ......

MSSQL触发器为什么自动删除了??????????

下面是我创建的一个触发器,当光伏电池数值超过设定的范围就会插入故障表,
但是在刚刚建立的触发器时,可以将故障数据插入到故障表,之后这个触发器就自动消失了.也就是创建过后只运行一次.
(奇怪的事,我的另一个表用 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号