Ò׽ؽØÍ¼Èí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

ÇóÒ»ÌõSQLÓï¾ä - MS-SQL Server / »ù´¡Àà

create table test(t_a int,t_b int,t_c datetime)

insert into test(t_a,t_b)values (1,1,'2000-01-01')
insert into test(t_a,t_b)values (1,2,'2000-02-01')
insert into test(t_a,t_b)values (1,3,'2000-03-01')
insert into test(t_a,t_b)values (2,1,'2000-04-01')
insert into test(t_a,t_b)values (2,1,'2000-05-01')
insert into test(t_a,t_b)values (2,2,'2000-06-01')

ÇóÒ»¾äSQLµÃ³ö
test±íÖеÄËùÓмǼ£¬ÒªÇó¶Ôt_aÏàͬµÄÖØ¸´¼Ç¼µÄֻѡȡ×îºóÒ»Ìõ¼Ç¼£¨°´t_cÅÅÐò£©£¬¼´t_c×î´óµÄ¼Ç¼¡£

shafa..




ÇëÏÂÃæµÄ²»ÓüÌÐø»ØÌûÁË£¬ÒѾ­µÃµ½ÕýÈ·´ð°¸ÁË£¬µ«ÊÇÏÖÔÚ»¹²»ÔÊÐí½áÌû¡£

SQL code:
create table test(t_a int,t_b int,t_c datetime)

insert into test values (1,1,'2000-01-01')
insert into test values (1,2,'2000-02-01')
insert into test values (1,3,'2000-03-01')
insert into test values (2,1,'2000-04-01')
insert into test values (2,1,'2000-05-01')
insert into test values (2,2,'2000-06-01')

--·¨1
select * from test t where not exists(select 1 from test where t_a=t.t_a and t_c>t.t_c)
--·¨2
select * from test t where t_c =(select MAX(t_c) from test where t_a=t.t_a)
--·¨3
select * from test t where t_c =(select top 1 t_c from test where t_a=t.t_a order by t_c desc)

/*
t_a t_b t_c
----------- ----------- -----------------------
1 3 2000-03-01 00:00:00.000
2 2


Ïà¹ØÎÊ´ð£º

sqlÓï¾ä¶à±í¶à×ֶβéѯ - MS-SQL Server / »ù´¡Àà

ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд 

ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......

Çë½ÌsqlÓï¾ä¡£ - Oracle / ¿ª·¢

ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
  ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......

sqlÓÅ»¯ - Oracle / »ù´¡ºÍ¹ÜÀí

select count(1) from FX_RETURNBOOKCHECKLIST fxreturnbo0_ where fxreturnbo0_.BOOKID='164 ' AND fxreturnbo0_.RETURNID='00025.S0000001' 
ÉÏÃæÒ»¸ö¼òµ¥µÄSQL,Ö´ÐÐʱ¼ä2.6à ......

ÇóÒ»SQL - MS-SQL Server / »ù´¡Àà

tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......

SQL server·Ö½âXML - MS-SQL Server / Ó¦ÓÃʵÀý

ÏÂÃæÊÇXML³õʼÎļþÄÚÈÝ
XML code:
<upd:Update xmlns:lar="http://schemas.microsoft.com/msus/2002/12/LogicalApplicabilityRules" xmlns:cmd="http://schemas.microsoft.com/msus/2002/12/Up ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ