SQL·ÖÒ³Óï¾ä
ÓйطÖÒ³ SQL µÄ×ÊÁϺܶ࣬ÓеÄʹÓô洢¹ý³Ì£¬ÓеÄʹÓÃÓαꡣ±¾È˲»Ï²»¶Ê¹ÓÃÓα꣬ÎÒ¾õµÃËüºÄ×Ê¡¢Ð§Âʵͣ»Ê¹Óô洢¹ý³ÌÊǸö²»´íµÄÑ¡Ôñ£¬ÒòΪ´æ´¢¹ý³ÌÊǾ¹ýÔ¤±àÒëµÄ£¬Ö´ÐÐЧÂʸߣ¬Ò²¸üÁé»î¡£ÏÈ¿´¿´µ¥Ìõ SQL Óï¾äµÄ·ÖÒ³ SQL °É¡£
·½·¨1£º
ÊÊÓÃÓÚ SQL Server 2000/2005
SELECT TOP Ò³´óС *
from table1
WHERE id NOT IN
(
SELECT TOP Ò³´óС*(Ò³Êý-1) id from table1 ORDER BY id
)
ORDER BY id
·½·¨2£º
ÊÊÓÃÓÚ SQL Server 2000/2005
SELECT TOP Ò³´óС *
from table1
WHERE id >
(
SELECT ISNULL(MAX(id),0)
from
(
SELECT TOP Ò³´óС*(Ò³Êý-1) id from table1 ORDER BY id
) A
)
ORDER BY id
·½·¨3£º
ÊÊÓÃÓÚ SQL Server 2005
SELECT TOP Ò³´óС *
from
(
SELECT ROW_NUMBER() OVER (ORDER BY id) AS RowNumber,* from table1
) A
WHERE RowNumber > Ò³´óС*(Ò³Êý-1)
Ïà¹ØÎĵµ£º
SQL ServerÈ«ÎÄË÷ÒýµÄ¸öÈË×ܽá(ÏÂ)-¹ØÓÚÖÐÎÄ·Ö´Ê
(2005-11-14 04:32:01)
תÔØ
·ÖÀࣺÉî¶ÈÑо¿
ÔÚʹÓÃSQL SearchµÄ¹ý³ÌÖУ¬»¹·¢ÏÖÁËÒ»¸öÎÊÌ⣺Ëü¶ÔÖÐÎÄ£¬ÊÇ°´×ִַʵģ¬ÏÂÃæÎÒ½âÊÍһϣº
±ÈÈç¶Ô'²©¿ÍÌóÉÔ±ºÜ¶àÊÇMVP'Õâ¾ä»°£¬¼ÙÈçÒ»¸ö¸öµÄ×ÖµÄ×÷Ë÷Òý£¬»á±ÈʹÓÃ'²©¿ÍÌÃ','³ÉÔ±',MVP'¼¸¸ö´Ê×÷Ë÷ÒýÉú³ÉµÄË ......
¼ÙÉèÏÖÔÚNews±íÓÐÒÔÏÂ×Ö¶Î
News_Id,News_Title,News_IsSetTop,News_SetTopTime
ÆäÖÐNews_IsSetTop(char(1))ÊÇ“ÊÇ·ñÖö¥”µÄº¬Ò壻News_SetTopTime(DateTime)ÊÇÖö¥Ê±¼ä£»
ÏÖÔÚҪʵÏÖ£ºÈç¹ûNews_IsSetTopΪ"1"ʱ £¬ORDER BY News_IsSetTop DESC,News_Id DESC£»News_IsSetTopΪ"0"ʱ£¬ORDER BY News_ID DESC ......
--Óï ¾ä ¹¦ ÄÜ
--Êý¾Ý²Ù×÷
SELECT --´ÓÊý¾Ý¿â±íÖмìË÷Êý¾ÝÐкÍÁÐ
INSERT --ÏòÊý¾Ý¿â±íÌí¼ÓÐÂÊý¾ÝÐÐ
DELETE --´ÓÊý¾Ý¿â±íÖÐɾ³ýÊý¾ÝÐÐ
UPDATE --¸üÐÂÊý¾Ý¿â±íÖеÄÊý¾Ý
--Êý¾Ý¶¨Òå
CREATE TABLE --´´½¨Ò»¸öÊý¾Ý¿â±í
DROP TABLE --´ÓÊý¾Ý¿âÖÐɾ³ý±í
ALTER TABLE --ÐÞ¸ÄÊý¾Ý¿â±í½á¹¹
CREATE VIEW --´´½¨Ò»¸öÊÓͼ
DRO ......
--´´½¨±íTongXunLu
CREATE TABLE TongXunLu
(
[tName] nvarchar(30),
[tAddress] nvarchar(50),
[tEmail] varchar(50)
)
--´´½¨±í students
CREATE TABLE students
(
[sId] int IDENTITY (1, 1) primary key NOT NULL ,
[sName] varchar (50) NOT ......
SQLÖÐround£¨£©º¯ÊýÓ÷¨
SQL round()Ïê½â
roundÓÐÁ½¸öÖØÔØ,Ò»¸öÓдøÓÐÁ½¸ö²ÎÊýµÄ,Ò»¸öÊÇ´øÓÐÈý¸ö²ÎÊýµÄ,
ÿһ¸ö²ÎÊý¶¼ÏàͬÊÇÒª´¦ÀíµÄÊý,
1.´øÓÐÁ½¸ö²ÎÊý.ÿ¶þ¸ö²ÎÊýÊÇСÊýµãµÄ×ó±ßµÚ¼¸Î»»òÓұߵڼ¸Î»,·Ö±ðÓÃÕý¸º±íʾ.×ó±ßΪ¸º,ÓÒ±ßΪ¸º.ΪËÄÉáÎåÈë.
select round(748.585929,-1) 750.000000
select round(748.58592 ......