Óиö±í SC(S#,C#,G) ÆäÖÐ S#,C#,G·Ö±ð±íʾѧºÅ¡¢¿Î³Ì±àºÅ ºÍ ³É¼¨
ͳ¼ÆÍ¬Ê±Ñ¡ÐÞ¡¯C1¡¯ºÅ¿Î³ÌºÍ¡¯C2¡¯ºÅ¿Î³ÌµÄËùÓÐѧÉúÖУ¬
C1 ³É¼¨±ÈC2µÃ·Ö¸ßµÄѧÉúѧºÅ¼°ÏàÓ¦Á½ÃŵĿ¼ÊԳɼ¨
×÷ÒµÌ⣬¼ø¶¨Íê±Ï
SQL code:
create table #sc(s# varchar(10),c# varchar(10),G int)
insert into #sc
select '001','C1',100 union all
select '001','C2',70 union all
select '002','C1',60 union all
select '002','C2',70 union all
select '003','C1',90 union all
select '003','C2',80 union all
select '004','C2',83
select *from #sc where s# in(
select a.s# from #sc a join #sc b on a.s#=b.s#
and a.G>b.G AND a.c#='C1')
SQL code:
/*=============================================*/
--> author:Ken Wong
--> Add date:2009-12-05 12:04:42
/*=============================================*/
--> ²âÊÔÊý¾Ý£º@table
declare @table table([S#] varchar(2),[C#] varchar(2),[G] numeric(4,1))
insert @table
select '01','c1',90.5 union all
select '01','c2',100 union all
select '01','c3',80 union all
select '02','c1',90 union all
select '02','c2',80.5 union all
select '02','c3',75 union all
select '03','c1',80 union all
select '04','c3',76
select *
from @table t
where S# in(select S# from @table
where C# in ('C
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......