ÈÕÆÚǰһÌìµÄsqlÓï¾ä
Êý¾Ý¿â±íAAA ×Ö¶ÎÈçÏÂ
a b c
A 10 2009-01-01
A 11 2009-01-02
A 12 2009-01-03
B 23 2009-01-01
B 24 2009-01-02
B 25 2009-01-03
C 17 2009-01-01
C 19 2009-01-02
C 25 2009-01-03
ÒªÇóËÑË÷³ö×î´óµÄÒ»ÌìÓë×î´óµÄÒ»Ìì֮ǰһÌ죬bµÄ±ÈÖµ£¬½á¹ûÈçÏÂ
A 12/11
B 25/24
C 25/19
SQL code:
sql server 2005:
select *
from (select id=row_number() over(order by c desc),* from tb) K
where id<=2
SQL code:
select m.a , cast(m.b as varchar) + '/' + cast(n.b as varchar) from
(select t.* , px = (select count(1) from tb where a = t.a and c > t.c) + 1 from tb t) m,
(select t.* , px = (select count(1) from tb where a = t.a and c > t.c) + 1 from tb t) n
where m.a = n.a and m.px = 1 and n.px = 2
SQL code:
create table tb(a varchar(10), b int, c datetime)
insert into tb values('A', 10 ,'2009-01-01')
insert into tb values('A', 11 ,'2009-01-02')
insert into tb values('A', 12 ,'2009-01-03')
insert
Ïà¹ØÎÊ´ð£º
ÏÖÔÚÓÐÁ½ÕÅ±í£ºÎÄÕÂÖ÷±íA(articleId,articleTitle)£¬ÎÄÕÂÆÀÂÛ±íB(commentId,articleId,commentTitle)
ÏÖÔÚÎÒÏëʵÏÖÕâÑùµÄ¹¦ÄÜ£ºÁгöÎÄÕÂÁÐ±í£¬ÆäÖÐÿƪÎÄÕ±êÌâÏÂÃæÁгö´ËÎÄÕµÄǰ2¸öÎÄÕÂÆÀÂÛ£¬ÇëÎÊsqlÓï¾äÔõôд°¡ ......
ÎÒÊÇÔÚtoadÖÐÊäÈë϶Îsql
declare
TYPE test_rec IS record(
code varchar(10),
name varchar(30)
);
v_book test_rec;
......
select count(1) from FX_RETURNBOOKCHECKLIST fxreturnbo0_ where fxreturnbo0_.BOOKID='164 ' AND fxreturnbo0_.RETURNID='00025.S0000001'
ÉÏÃæÒ»¸ö¼òµ¥µÄSQL,Ö´ÐÐʱ¼ä2.6à ......
tab1 ×Ö¶Î:billdate,goodsid,incount,inmoney,outcount,outmoney,endprice,endcount,endamt
tab2 ×Ö¶Î:goodsid,goodskind£¨ÉÌÆ·ÀàÐÍ£©
tab3 ×Ö¶Î:goodskind£¨ÉÌÆ·ÀàÐÍ£©,kindname
½á¹û£º
µÃµ½ÉÌÆ·ÀàÐÍÔÚÒ»¶Îʱ¼ä ......
ÄÄλÈÊÐÖÓй¦ÄÜÍêÕû¿ÉÓõÄSQLÏÂÔØµØÖ·ÄØ£¬ÎÒÓÐÒ»¸öµØÖ·£¬µ«Êǰ²×°ºó¹¦Äܲ»ÍêÕûÎÞ·¨Ê¹Óã¨Ã»ÓзþÎñÆ÷£©ÎÒÖªµÀµÄµØÖ·ÊÇ
http://down.xlylw.com/downlist/s_66_1.html
¿´À´£¬ÄãÖ»Äܵ½ÍøÉÏ×Ô¼ºËÑË÷ÁË!
×Ô¼º¶¯ÊÖ¾Í¿É ......