34,590
社区成员
发帖
与我相关
我的任务
分享
--> 测试数据: #T
if object_id('tempdb.dbo.#T') is not null drop table #T
create table #T (T1 varchar(1),T2 varchar(2),T3 varchar(2))
insert into #T
select 'A','12','43' union all
select 'A','MM','MM' union all
select 'B','XC','ED' union all
select 'C','DS','XX' union all
select 'C','ES','EE';
with T as
(
select id=row_number()over(partition by T1 order by T1),* from #T
)
select T1=case id when (select min(id) from T where T1=t.T1) then T1 else '' end, T2,T3 from T as t
/*
T1 T2 T3
---- ---- ----
A 12 43
MM MM
B XC ED
C DS XX
ES EE
*/
create table tb(t1 varchar(10),t2 varchar(10),t3 varchar(10))
insert into tb select 'A' , '12' , '43'
insert into tb select 'A' , 'MM' , 'MM'
insert into tb select 'B' , 'XC' , 'ED'
insert into tb select 'C' , 'DS' , 'XX'
insert into tb select 'C' , 'ES' , 'EE'
go
select t1=case when t2=(select min(t2) from tb where t1=a.t1) then t1 else '' end,
t2,t3
from tb a
go
drop table tb
/*
t1 t2 t3
---------- ---------- ----------
A 12 43
MM MM
B XC ED
C DS XX
ES EE
(所影响的行数为 5 行)
*/
=========================== 暂无考试 ===========================
" session("qi")=0 pd=0 pds=0 xz=0 xzs=0 tk=0 tks=0 zfen=pd*pds+xz*xzs+tk*tks else set rss=conn.execute("select * from examination order by examinationid desc ") if rss.eof then session("qi")=1 else session("qi")=rss("examinationid")+1 end if pd=rs("rightorwrongid") pds=rs("rightorwrongscore") Response.Write rs("rightorwrongscore") xz=rs("selectid") xzs=rs("selectscore") tk=rs("fillingid") tks=rs("fillingscore") zfen=pd*pds+xz*xzs+tk*tks end if %>
|