ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

§â¤­®æªº¸ê®Æ¥­§¡«á¼g¦b¤@­ÓÀx¦s®æ¤¤(ªÑ²¼ªº¤­¤é§¡½u)

§â¤­®æªº¸ê®Æ¥­§¡«á¼g¦b¤@­ÓÀx¦s®æ¤¤(ªÑ²¼ªº¤­¤é§¡½u)

¥»©«³Ì«á¥Ñ joey0415 ©ó 2010-6-21 08:26 ½s¿è



¦p¤Wªí¡A¤p§Ì·|§âSQL_2008¤¤ªº¸ê®Æ¡A¼´¥X¸ê®Æ©ñ¦bEXCEL¤¤¡A¨Ã¥ÎEXCEL¤¤­pºâ¦¬½L»ùªº¤­¤é§¡½u¡AÅ¥ªB¤Í»¡¡A¥i¥Hª½±µ¦bSQL_2008 ¤¤¡Aª½±µºâ¥X¤­¤é§¡½u¡A½Ð°Ý¤@¤U¡A­Y¦b¸ê®Æ®w¤¤­pºâªº¸Ü¡A½Ð°Ý»yªk¬°¦ó©O¡H

¦pªG¤£¦æªº¸Ü¡A­Y§â¸ê®Æ¼´¥X¨Ó¦bEXCEL¤¤­pºâ«á¡A¦A©ñ¦^¸ê®Æ®w¤¤¦s©ñ¡A³o¼Ë¦n¶Ü¡H

SELECT x.¤é´Á, AVG(y.³Ì§C) moving_average from
STOCK_DAY X, STOCK_DAY Y
where X.¤é´Á>= '2007-05-3 ...
kimbal µoªí©ó 2010-7-4 13:32


¬Ý¼Ë¤l¦n¹³¥i¥H¥Î¡A·PÁ¤À¨É

TOP

¥»©«³Ì«á¥Ñ kimbal ©ó 2010-7-4 13:37 ½s¿è

SELECT x.¤é´Á, AVG(y.³Ì§C) moving_average from
STOCK_DAY X, STOCK_DAY Y
where X.¤é´Á>= '2007-05-30'
AND x.¤é´Á BETWEEN y.¤é´Á AND dateadd(d,5,y.¤é´Á)
GROUP BY x.¤é´Á
ORDER BY x.¤é´Á

¦pªG¤£·Q¼g¦º'2007-05-30', ¥i¥Î (select MAX(¤é´Á) FROM (select TOP 5 ¤é´Á from STOCK_DAY ORDER BY ¤é´Á)) ¥N´À

°Ñ¦Ò
http://oreilly.com/catalog/transqlcook/chapter/ch08.html
À´±oµo°Ý,µª®×´N·|¦b¨ä¤¤

¤µ¤éの¤@¬íは  ©ú¤éにない
http://kimbalko-chi.blogspot.com
http://kimbalko.blogspot.com

TOP

¦^´_  joey0415
GOOGLE¦^ÂÐ
http://www.mobile01.com/topicdetail.php?f=512&t=1611893&last=20372916
...
PD961A µoªí©ó 2010-6-28 11:40



    ³o¤]¬O§Ú¦b§Oªººô¯¸¶K¹L¤F¡A¤£¹L³o¦ì¤j¤j¥u¦^µª¤@¥b¡A¦]¬°§Ú°£¤F­n¥­§¡¡AÁÙ­n¾ãÄæ³£¬O¦p¦¹¡A¦pªG¥Îexcel¤@¤U¤l´N°µ§¹¤F¡A§Ú¥u·Q¬Ý¬Ýsqlªº¤èªk¡Aµ²ªG·|Åܦp¦ó¡I

ÁÂÁÂ

TOP

¦^´_ 1# joey0415
GOOGLE¦^ÂÐ
http://www.mobile01.com/topicdetail.php?f=512&t=1611893&last=20372916
    1. ¥Î Select MAX(¤é´Á) from STOCK_AAA
´N¥i¥H¨ú±o³Ì«á¤@¤Ñªº¤é´Á¡C
©Ò¥H²Õ¦X°_¨Ó´N¥i¥H±o¨ì
Select * from STOCK_AAA where ¤é´Á=(Select MAX(¤é´Á) from STOCK_AAA)
2.
­n¨ú±o«e¤­¤Ñªº¤é´Á¶°¦X
Select TOP 5 ¤é´Á from STOCK_AAA where ¤é´Á<= '2007/5/28' ORDER BY ¤é´Á DESC
¥Î³Ì¤p­È¡A´N¥i¥H¨ú¨ì¤­¤Ñ«eªº¨º­Ó¤é´Á
SELECT MIN(¤é´Á) FROM (Select TOP 5 ¤é´Á from STOCK_AAA where ¤é´Á<= '2007/5/28' ORDER BY ¤é´Á DESC)
¦A¨Ó¥Î between + ¥­§¡­È
³Ì«á¥þ³¡²Õ¦X¦¨¤@­Ó SQL
¨ä¹ê¨ì³o»ò½ÆÂø¡A¥Î Storage Procedure ©Î °t¦X VIEW ·|¤ñ¸û²³æ©úÁA

TOP

        ÀR«ä¦Û¦b : ¸Ü¦h¤£¦p¸Ü¤Ö¡A¸Ü¤Ö¤£¦p¸Ü¦n¡C
ªð¦^¦Cªí ¤W¤@¥DÃD