Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö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 / ¿ª·¢

ÎÒÓÐÒ»¸ö±í£¬½á¹¹ÊÇÕâÑù¡£
  ת³ö µ¥Î» תÈ뵥λ ±ÊÊý ½ð¶î
date(Ö÷) outid(Ö÷) inid(Ö÷) num amt
2009 1 2 1 500 Ϊ 1 µ¥Î» ÔÚ2009Ä ......

ÇóÒ»SQL - MS-SQL Server / »ù´¡Àà

tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......

ÇóÒ»¸öSQLÓï¾ä - MS-SQL Server / »ù´¡Àà

×Ö¶Î1,×Ö¶Î2.....×Ö¶ÎN,Status,ParentID
1,Name1....test1,1,99
1,Name1....test1,3,99
1,Name2....test2,1,101
1,Name2....test2,3,101
1,Name3....test3,2,101
1,Name1....test1,4,101
ÏëÒªµÄ½á¹ûÊÇ:
1,Na ......

Çë½ÌSQLSERVERµÄÁ½¸öÎÊÌâ - MS-SQL Server / ÒÉÄÑÎÊÌâ

1¡£ÔõÑùʹxp_cmdshellÄÜÍêÕûÊä³ö³¬¹ý255¸ö×Ö·ûµÄ×Ö·û´®¡£
2¡£select ʱ£¬¼ìË÷ËÙ¶ÈÊÇÓëfromºóµÄ TABLE˳ÐòÓйأ¬»¹ÊÇÓëwhereÌõ¼þµÄ˳ÐòÓйØ(TABLEÊý¾Ý¶àÉÙ )
ÔÚϵͳÊôÐÔÉ趨ÀïÓиöÑ¡Ïî,¿ÉÒÔÐ޸ĵ¥×Ö¶ÎÊä³ö×ÖÊýÏÞÖÆ. ......

Çóһʱ¼ä±È½ÏµÄSQL Ö¸Áî - MS-SQL Server / »ù´¡Àà

±íÊý¾Ý
COL1 COL2 COL2 COL4 COL5
----------------------------------------------------------------------------------------------
2010-05-05 00:00 ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ