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

¼òµ¥sql²éѯ

Ò»¸öÓû§±íUser£¨id,name£©Ò»¸öÎÄÕ±íAtical(id,UserId,content,EntryTime)
²é³öÿ¸öÓû§×îз¢±íµÄһƪÎÄÕ¡£ÔÚÏߵȴýÖС£¡£¡£¡£
SQL code:
select a.*,
b.*
from [User] a,Atical b
where a.id=b.UserId
and not exists(select 1 from Atical where UserId=b.UserId and EntryTime>t.EntryTime)


Â¥ÉϵϹÔÚÂð£¿ÄãµÄ·½·¨Ã²ËƲ»Ðа¡¡£ÕâÑù²é³öµÄÊÇ×îºó·¢±íµÄһƪÎÄÕ°¡¡£ÎÒÒªµÄÊÇÿ¸öÓû§µÄ×îºó·¢±íµÄһƪÎÄÕÂ

SQL code:
--¾ÍÊÇÿ¸öÓÃ戶°¡,UserId²»¾ÍÊÇÓÃ戶麼
select a.*,
b.*
from [User] a,Atical b
where a.id=b.UserId
and not exists(select 1 from Atical where UserId=b.UserId and EntryTime>b.EntryTime)


with cte as(
select
      *,
  row_number() over(partition by a.userid order by EntryTime desc) as rn
from Atical
)

select a.*,b.*
from [User] a,cte b
where a.id=b.UserId and b.rn=1

ÒýÓÃ
Â¥ÉϵϹÔÚÂð£¿ÄãµÄ·½·¨Ã²ËƲ»Ðа¡¡£ÕâÑù²é³öµÄÊÇ×îºó·¢±íµÄһƪÎÄÕ°¡¡£ÎÒÒªµÄÊÇÿ¸öÓû§µÄ×îºó·¢±íµÄһƪÎÄÕÂ


½¨ÒéÂ¥Ö÷²âÊÔһϣ¬²âÊÔ½á¹û¼´ÕæÀí

select userid,name,content,b.id,entrytime
from user a,atical b
where a.id=b.userid and entrytime in (sel


Ïà¹ØÎÊ´ð£º

sqlССµÄÒÉÎÊ - .NET¼¼Êõ / C#

¿ÉÄÜÒòΪ¹¤×÷µÄÔ­Òò ½Ó´¥Êý¾Ý¿âÕâ¿é±È½ÏÉÙ£¬Ö®Ç°¶¼ÊÇ×ö³ÌÐòÕâ¿é£¬Êý¾Ý¿âÕâ¿é¶¼ÓÐרÃŵÄÈËÀ´×ö ·Ö¹¤¶¼ºÜÃ÷ϸ ËùÒÔ¶ÔÊý¾Ý¿âÕâÒ»¿éÍêÈ«²»Á˽⡣ǰ¶Îʱ¼ä È¥ÃæÊÔÁ˼¸¼Ò¹«Ë¾ ¼¸ºõ¶¼ÊÇÔÚÊý¾Ý¿âÕâ¿é¹ÒµôµÄ Á¬¸ö¼òµ¥µÄSQ ......

Ò»¸öpl/sqlÎÊÌâ - Oracle / ¿ª·¢

ÎÒÊÇÔÚtoadÖÐÊäÈë϶Îsql
  declare
  TYPE test_rec IS record(
  code varchar(10),
  name varchar(30)
  );
  v_book test_rec;
    ......

SQL clr - MS-SQL Server / ·Ç¼¼Êõ°æ

ÏëÓÃSQL CLR×öÈçϵĴ洢¹ý³Ì,µ«ÊÇ·¢ÏÖ±¨´í: 
{ÓÉÓÚ´úÂëÒѾ­¹ýÓÅ»¯»òÕß±¾»ú¿ò¼ÜλÓÚµ÷ÓöÑÕ»Ö®ÉÏ£¬ÎÞ·¨¼ÆËã±í´ïʽµÄÖµ¡£} 
¶øÇÒÈç¹ûÊý¾Ý´Ócase 1ͨ¹ýʱ¾ÍÊÇÕýÈ·µÄ,´Ócase 2ͨ¹ýʱ´íÎó 
²¢ÇÒÔÚc ......

sqlÓÅ»¯ - Oracle / »ù´¡ºÍ¹ÜÀí

select count(1) from FX_RETURNBOOKCHECKLIST fxreturnbo0_ where fxreturnbo0_.BOOKID='164 ' AND fxreturnbo0_.RETURNID='00025.S0000001' 
ÉÏÃæÒ»¸ö¼òµ¥µÄSQL,Ö´ÐÐʱ¼ä2.6à ......

MS SQL×÷ÒµÎÊÌâ - MS-SQL Server / Ó¦ÓÃʵÀý

ÈçºÎÔÚSQL2005ÖÐÉ趨¶¨Ê±×÷Òµ£¬±ÈÈç˵¶¨Ê±ÇåÀíijЩ±íµÄÊý¾Ý£¬
»òÕßÊǶ¨Ê±µÄ½«Ä³Ð©±íµÄÊý¾Ýµ¼³öexcel£¡
ÔÚÏߵȴý£¬¼±¼±¼±£¬×îºÃÊÇÏêϸ²½Ö裡
֮ǰÎÒ×öµÄ×÷ÒµÓеãÎÊÌ⣡
°ïUP

²Î¿¼:http://hi.baidu.com/toiota ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØÍ¼ | ¸ÓICP±¸09004571ºÅ