ÇóÒ»Ìõ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
Ïà¹ØÎÊ´ð£º
ÎÒÓжà¸ö±íA B C ½á¹¹ÊÇÒ»ÑùµÄ£¬¶¼ÓÐ2¸ö×Ö¶ÎnameºÍcontent,ÎÒÒªËÑË÷ËùÒÔ±íËùÓÐ×Ö¶ÎÖаüº¬¡°Öйú¡±µÄÄÚÈÝ Õâ¸öSQLÓï¾äÔõôд
ÈçºÎ½«¶à¸ö±íµÄ²éѯ½á¹ûÁ¬³ÉÒ»¸ö±í Õâ¸öSQLÓï¾äÔõôд ±íµÄ½á¹¹ÊÇÒ»ÑùµÄ
ÀýÈç£ ......
ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......
select count(1) from FX_RETURNBOOKCHECKLIST fxreturnbo0_ where fxreturnbo0_.BOOKID='164 ' AND fxreturnbo0_.RETURNID='00025.S0000001'
ÉÏÃæÒ»¸ö¼òµ¥µÄSQL,Ö´ÐÐʱ¼ä2.6à ......
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......
ÏÂÃæÊÇ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 ......