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

Ò»¸ö·³È˵ÄsqlÌâÄ¿ - MS-SQL Server / ÒÉÄÑÎÊÌâ

t_hykbgjl ¼Ç¼ÁË»áÔ±¿¨Ã¿´ÎµÄ·¢Éú¶î(nFse) ¡¢Óà¶î£¨nYe£©¼°¿¨ºÅ£¨sKH£©,¶ÔÓÚͬһ»áÔ±¿¨£¬ÉÏÒ»Ìõ¼Ç¼µÄÓà¶î¼ÓÉϱ¾´Î·¢Éú¶îÓ¦µÈÓÚ±¾´ÎµÄÓà¶î¡£·ñÔòÕʽ«²»Æ½¡£¼Ç¼ºÅΪsJlbh,¶ÔÓÚͬһ»áÔ±£¬ÏÂÒ»¼Ç¼ºÅ±ÈÉÏÒ»¼Ç¼ºÅ´ó1,Çëд³öÁгöËùÓлáÔ±¿¨²»Æ½ÕʼǼµÄSqlÓï¾ä¡£

Çó½â
Â¥Ö÷À´µã²âÊÔÊý¾Ý ¿´¿´

select a.* 
from t_hykbgjl a left join t_hykbgjl b
on a.sJlbh=b.sJlbh+1 
where b.nYe+a.nFse<>a.nYe



ÒýÓÃ
t_hykbgjl ¼Ç¼ÁË»áÔ±¿¨Ã¿´ÎµÄ·¢Éú¶î(nFse) ¡¢Óà¶î£¨nYe£©¼°¿¨ºÅ£¨sKH£©,¶ÔÓÚͬһ»áÔ±¿¨£¬ÉÏÒ»Ìõ¼Ç¼µÄÓà¶î¼ÓÉϱ¾´Î·¢Éú¶îÓ¦µÈÓÚ±¾´ÎµÄÓà¶î¡£·ñÔòÕʽ«²»Æ½¡£¼Ç¼ºÅΪsJlbh,¶ÔÓÚͬһ»áÔ±£¬ÏÂÒ»¼Ç¼ºÅ±ÈÉÏÒ»¼Ç¼ºÅ´ó1,Çëд³öÁгöËùÓлáÔ±¿¨²»Æ½ÕʼǼµÄSqlÓï¾ä¡£

Çó½â

--sql 2000ÓÃ×Ó²éѯ
SQL code:
select m.* , n.* from
(
select t.* , px = (select count(1) from t_hykbgjl where sKH = t.sKH and ¼Ç¼ºÅ < t.¼Ç¼ºÅ) + 1 from t_hykbgjl t
) m,
(
select t.* , px = (select count(1) from t_hykbgjl where sKH = t.sKH and ¼Ç¼ºÅ < t.¼Ç¼ºÅ) + 1 from t_hykbgjl t
) n
where m.sKH = n.sKH and n.px = m.px - 1 and m.nYe + n.nFse <> m.nYe



--sql 2005ÓÃrow_number
SQL code:
select m.* , n.* from
(
select t.* , px = row_number() over(


Ïà¹ØÎÊ´ð£º

SQL·ÖÒ³ÓëOracle·ÖÒ³µÄÒÉÎÊ£¿ - Java / Web ¿ª·¢

ÕâÀïÏëÁ˽âÏ£¬¹ØÓÚSQL ServerÖзÖÒ³ºÍOracleÖзÖÒ³£»
ƽ³£Ð´Ó¦ÓóÌÐòµÄʱºò£¬±ÈÈçÓõÄÓïÑÔÊÇJava£¬ÓиöÁбíÒ³Ã棬ÐèÒª¶ÔÊý¾Ý·ÖÒ³ÏÔʾ£»
ÕâÀïÒª·ÖÒ³ÄѵÀ²»ÐèÒª½èÖúJava£¬¶øÖ±½ÓsqlÄÜÖªµÀ·ÖÒ³Âð£¬ÆðÂëÒ²Òª´«¸öÒ³Âë½ ......

sqlÓï¾äÎÊÌâ - MS-SQL Server / ÒÉÄÑÎÊÌâ

ÏÖÔÚÓÐÒ»¸ö²¿Ãűídept£¨²¿ÃÅÃû³Æ£¬²¿Ãźš£¡££©ÓÐÒ»¸öÈËÔ±±íemp£¨ÐÕÃû£¬ÈËÔ±±àºÅ£¬Ö°Î»£¬Ð½×Ê£¬²¿ÃÅ£©
emp±íÖеÄÄÚÈÝÊÇÕâÑùµÄ£º
a 1 ¹¤³Ìʦ 3000 Èí¼þ²¿
b 2 ÆÕͨԱ¹¤ 2000 Ó²¼þ²¿
c 3 ¹¤³Ìʦ 4000 Ó²¼þ²¿
d ......

sqlÓï¾äÎÊÌâ - Java / Web ¿ª·¢

select o_customer,o_price from orders having o_price >=avg(o_price)
select o_customer,o_price from orders where o_price >=(select avg(o_price) from orders)
ÎҸоõûÓÐÇø±ð°¡£¬ÔõôÔÚmysql»áÓÐ ......

asp wap sqlÓï¾äÖлñÈ¡µÄºº×Ö²»ºÃÊ - Web ¿ª·¢ / ASP

SQL code:

rs.open "select * from guide where city_name='±±¾©' order by pai desc",conn,1,1
do while not rs.eof or rs.bof
¡£¡£
¡£¡£
¡£¡£
rs.movenext
loop
Õâ¸ösqlÓï¾äÔÚwapÕ¾Àï ±¾ÉíÓÐ ......

SQLÄܽøÐжþ½øÖƵÄɸѡÂ𣿠- MS-SQL Server / »ù´¡Àà

ÎÒÓÐÒ»¸ö×Ö¶ÎÊÇ varchar(1) ÀàÐÍ£¬¶þ½øÖƱíʾҲ¾ÍÊÇ8λµÄ ¡®0000 0000¡¯
±ÈÈçÕâ¸öʱºòÎÒÐèҪɸѡ³öÕâ¸ö×Ö¶ÎΪËùÓÐµÄ ¡®0000 0100¡¯µÄÐУ¬ÇëÎÊSQLÄÜʵÏÖÕâÑùµÄ¡°Î»¡±µÄɸѡÂð£¿
лл~~~

ÓÐλ²Ù×ݺ¯ÊýÂ𣿲»ÐоÍ× ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ