SQL·Ö×é²éѯ ¿ÉÒÔ¶Ôÿһ×éÖÐÐÅÏ¢Á¿É¸Ñ¡
¿´¿´ÒÔÏÂSQLÓï¾ä£º
select row_number() over(partition by xs.xsbh, xs.kch order by coalesce(xs.bkxnxqh, xs.xnxqh) desc) rn
row_number()£º´ú±íÁÐ
partition by ´ú±í°´Ê²Ã´½øÐзÖ×é
order by¶Ôÿһ×éÐÅÏ¢½øÐÐÅÅÐò
coalesce()ÊÇÌæ»»µÄÒâ˼ ÀýÈ磺ÉÏÃæµÄSQLÓï¾äµÄÒâ˼ÊÇ£¬Èç¹ûbkxnxqhΪ¿Õ£¬ÄÇô¾ÍÈ¥xnxqh
rn ´ú±í²éѯ½á¹ûµÄÐòºÅ
Ïà¹ØÎĵµ£º
--ͨ¹ýsqlÆóÒµ¹ÜÀíÆ÷Ð޸ĺÍɾ³ýa±íÖÐÊý¾Ýʱ»á³öÏÖ´íÎó
--sqlÆóÒµ¹ÜÀíBug£¬Í¨¹ý³ÌÐò»òÖ´ÐÐsqlÓï¾ä¸üÐÂa±íÊý¾ÝûÓÐÎÊÌâ
--Ìí¼Ó
Insert a (FName, FCode, FOther) Values('11','2222','33')
--ÐÞ¸Ä
Update a Set FName='22_Edit' Where FCode='22'
--ɾ³ý
Delete a Where FCode='22'
--²é¿´a/b±íÊý¾Ý
Select * from a ......
¼Ü¹¹£¨Schema£©¡£Î¢ÈíµÄ¹Ù·½ËµÃ÷£¨MSDN£©£º
"Êý¾Ý¿â¼Ü¹¹ÊÇÒ»¸ö¶ÀÁ¢ÓÚÊý¾Ý¿âÓû§µÄ·ÇÖظ´ÃüÃû¿Õ¼ä£¬Äú¿ÉÒÔ½«¼Ü¹¹ÊÓΪ¶ÔÏóµÄÈÝÆ÷"£¬Ïêϸ²Î¿¼
http://technet.microsoft.com/zh-cn/library/ms190387.aspx.ÎÒÃÇÖªµÀ£¬ÔÚJAVAÖУ¬ÃüÃû¿Õ
¼äÃûÆäʵ¾ÍÊÇÎļþ¼ÐÃû¡£Òò´ËÎÒÃǷdz£Ã÷È·Ò»µã£ºÒ»¸ö¶ÔÏóÖ»ÄÜÊôÓÚÒ»¸ö¼Ü¹¹£¬¾ÍÏ ......
ʹÓÃsqlÓï¾ä»ñµÃµ±Ç°ÔÂÌìÊý
--»ñµÃµ±ÔÂÌìÊý
select day(dateadd(mm,1,getdate())-day(getdate())) as ±¾ÔÂÌìÊý ;
select getdate() as µ±Ç°ÈÕÆÚ;
&nb ......