昨天发的这个帖子:http://topic.csdn.net/u/20100407/15/1af60691-1b11-4a0a-bf85-6187add9fb4f.html
SQL code:
select tId,max(class1) maxClass
from(select tId,class1 from tb1 union all select tId,class2 from tb1) tt
group by tId
--2
select tId,max(cc1) maxClass
from(select tId,class1+class2 cc1 from tb1 union all select tId,class1+class2 cc2 from tb1) tt
group by tId
现在我要显示这个的结果
tId tName maxClass maxSum
1 test2 35 60
2 test21 85 125
3 test32 70 140
请问怎么把子查询合并起来,谢谢。
select tId,max(CASE WHEN class1>class2 THEN class1 ELSE class2 END) as maxClass,
max(class1+class2) as maxSum
from tb1
group by tId
以上假设class1 和 class2都不能为Null值
比如再加一个字段:
SQL code:
create table tb1
(
tId int,
tName nvarchar(20),
class1 int,
class2 int,
class3 int
)
insert into tb1
select 1,'test',10,20,30
union all
select 1,'test1',20,35,25
union all
select 1,'test2',30,30,40
union all
select 2,'test21',30,85,20
union all
select 2,'test22',50,75,90
union all
select 3,'test31',60,65,40
union all
select 3,'test32',70,70,50
那又怎么解决
一个总站.三个子站共四个ASP开发的站点;数据库是MSSQL2000;四个站各有自己的数据库(四个站点的库结构都是一样的.),各有自己的信息添加后台,四个站是独立的.四个站都在同一个服务器中.
现在需要现实:
一.如何让总站 ......
有一个数据库里只有2W条数据不到,却有500M那么大,怎么回事啊?是ACCESS的数据库。后来我把ACCESS导入到MSSQL中,也占用了500M左右的空间,如果压缩数据库呢?请高手指点
压缩数据库?能做到么...
期待高人指点 我 ......
用了FCKeditor的编辑器,存入普通文章后,可以更新。当存入word的那种表格格式的文章时候,就出现无法更新的问题。 <httpRuntime maxRequestLength="2097151" executionTimeout="43200"/&g ......