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

ÓÃÒ»¾äSQLÈ¡³öµÚ m Ìõµ½µÚ n Ìõ¼Ç¼µÄ·½·¨

 1 --´ÓTable ±íÖÐÈ¡³öµÚ m Ìõµ½µÚ n ÌõµÄ¼Ç¼£º(Not In °æ±¾)
 2
 3 SELECT TOP n-m+1 *
 4 from Table
 5 WHERE (id NOT IN (SELECT TOP m-1 id from Table )) 
 6
 7
 8 --´ÓTABLE±íÖÐÈ¡³öµÚmµ½nÌõ¼Ç¼ (Exists°æ±¾)
 9
10 SELECT TOP n-m+1 * from TABLE AS a WHERE Not Exists
11 (Select * from (Select Top m-1 * from TABLE order by id) b Where b.id=a.id )
12 Order by id
13
14
15 --mΪÉϱ꣬nΪϱê,ÀýÈçÈ¡³öµÚ8µ½12Ìõ¼Ç¼,m=8,n=12,TableΪ±íÃû
16
17 Select Top n-m+1 * from Table
18 Where Id>(Select Max(Id) from
19 (Select Top m-1 Id from Table Order By Id Asc) Temp)
20 Order By Id Asc 


Ïà¹ØÎĵµ£º

SQL SERVERµ¥Ò³Êý¾Ý´æ´¢ÐÐÊý¼ÆËã

 Ó¦ÓÃʾÀý£º
-- ´´½¨2¸ö²âÊÔ±í
CREATE TABLE [dbo].[Table_2019]([Data] [nchar](2019) NOT NULL)
CREATE TABLE [dbo].[Table_2020]([Data] [nchar](2020) NOT NULL)
go
-- Ìî³äÊý¾Ý
declare @i int
set @i = 0
while(@i < 20)
begin
    insert Table_2019(Data) values('')
  ......

sql server µÄ moneyÀàÐÍ

sql serverµÄ money ÀàÐÍÆäʵ¾ÍÊÇСÊýÀàÐÍ decimal £¬ÎÒ²»Ï²»¶ÓÃËü£¬ÒòΪÓÐÒ»´Îʲô¹¤¾ßÉú³É£¬·¢ÏÖËü×Ô¶¯°ÑmoneyÀàÐÍת»»³ÉÁËdecimalÀàÐÍÁË£¬ÓëÆäÈÃËüת£¬»¹²»Èç×Ô¼ºÉè¼ÆÊý¾Ý¿âʱ½«»õ±ÒÀàÐÍ×Ö¶ÎÉèÖÃΪ decimal ÀàÐͲ»¾ÍµÃÁË£¬·ÏÄÇʸÉÂ   ×Ö½ÚÊý ³¤¶È(СÊýµãÇ°.СÊýµãºó) ......

SQL ServerÈÕÖ¾Çå³ýµÄÁ½ÖÖ·½·¨

 ÔÚʹÓùý³ÌÖдó¼Ò¾­³£Åöµ½Êý¾Ý¿âÈÕÖ¾·Ç³£´óµÄÇé¿ö£¬ÔÚÕâÀï½éÉÜÁËÁ½ÖÖ´¦Àí·½·¨……
¡¡¡¡·½·¨Ò»
¡¡¡¡Ò»°ãÇé¿öÏ£¬SQLÊý¾Ý¿âµÄÊÕËõ²¢²»Äܴܺó³Ì¶ÈÉϼõСÊý¾Ý¿â´óС£¬ÆäÖ÷Òª×÷ÓÃÊÇÊÕËõÈÕÖ¾´óС£¬Ó¦µ±¶¨ÆÚ½øÐд˲Ù×÷ÒÔÃâÊý¾Ý¿âÈÕÖ¾¹ý´ó¡£
¡¡¡¡1¡¢ÉèÖÃÊý¾Ý¿âģʽΪ¼òµ¥Ä£Ê½£º´ò¿ªSQLÆóÒµ¹ÜÀíÆ÷£¬ÔÚ¿ØÖÆ̨¸ùÄ ......

½ÌÄãÍæתSQL Server´æ´¢¹ý³Ì

 Ê×ÏȽéÉÜÒ»ÏÂʲôÊÇ´æ´¢¹ý³Ì£º´æ´¢¹ý³Ì¾ÍÊǽ«³£ÓõĻòºÜ¸´ÔӵŤ×÷£¬Ô¤ÏÈÓÃSQLÓï¾äдºÃ²¢ÓÃÒ»¸öÖ¸¶¨µÄÃû³Æ´æ´¢ÆðÀ´£¬²¢ÇÒÕâÑùµÄÓï¾äÊÇ·ÅÔÚÊý¾Ý¿âÖеģ¬»¹¿ÉÒÔ¸ù¾ÝÌõ¼þÖ´Ðв»Í¬SQLÓï¾ä£¬ ÄÇôÒÔºóÒª½ÐÊý¾Ý¿âÌṩÓëÒѶ¨ÒåºÃµÄ´æ´¢¹ý³ÌµÄ¹¦ÄÜÏàͬµÄ·þÎñʱ£¬Ö»Ðèµ÷ÓÃexecute,¼´¿É×Ô¶¯Íê³ÉÃüÁî¡£
¡¡¡¡Çë´ó¼ÒÀ´Á˽âÒ»ÏÂ´æ´ ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ