´ó¼ÒºÃ,ÔÚ±íAÖÐ,ÓÐ×Ö¶ÎmÓën,Êý¾ÝÈçÏÂ:
m n j
Êé 1 0
µçÄÔ 2 0
µçÄÔ 2 0
Êé 3 0
µçÄÔ 4 0
µçÄÔ 4 0
Êé 5 0
Êé 5 0
ÇëÎÊ,Î ......
Êý¾Ý¿âÖÐÓиö±íµÄ½á¹¹ÊÇÕâÑùµÄ£º£¨student£©
sno sname age
001 sb 10
001 ......
ÓÐÕâÑùÒ»¸öÐèÇ󣬲éѯµ±ÌìµÄÊý¾Ý
±íÀï±ßÓиötime×ֶΣ¬ÕâÑù¸ÄÔõô²é°¡£¿
select * from table where time>µ±Ìì0µã and time <µ±Ìì24µã
ÍøÉÏÒ²²éÁËÏÂ
select * from table where time BETWEEN µ±Ìì0µã and µ±Ìì24µã
µ«ÊǾßÌåÔõô×ö¾Í²»ÖªµÀÁË
ÄÇλ°ïæ˵Ï£¬Ð»Ð»¡£
sel ......
Create Table #Test
(
FItemID int,
FParentID int,
FLevel int,
FName varchar(30)
)
Insert into #Test
Select 1,0,1,'11111' union all
Select 2,1,2,'222222' union all
Select 3,2,3,'3333333' union all
Select 4,1,2,'444444' union all ......
select example_a from example where time <=2009-11-01 and time >= 2009-01-01
ÔÚÕâ¸öSQLÓï¾äÀïÄÜ·ñÖ±½ÓµÃµ½µÚÒ»ÐÐexample_aÊý¾ÝºÍ×îºóÒ»ÐÐexample_aÊý¾ÝÄØ£¿
ÎÒÏÖÔڵĽâ¾ö·½°¸ÊÇTOP 1£¬È»ºóÔÚµ¹ÐòTOP 1£¬ÕâÑùµÄ»°Ó°ÏìЧÂÊ¡£
¼Ó¸ö×ÔÔöÁÐ
ÓÃmax(id)ºÍmin(id)ÄØ£¿
Ö»ÄÜÕâÑù°É.
½â¾ö·½ ......
±íA£º
epno epdate epmoney
001 2009-11-19 10:12:28.950 5.00
001 2009-11-19 10:13:28.950 2.00
002 2009-11-19 10:22:28.950 5.00
001 2009-11-20 10:05:28.950 5.00
002 2009-11-20 10:21:28.950 ......