Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
gangadhara.ms
Aged Yak Warrior
549 Posts |
Posted - 2012-02-14 : 03:15:33
|
Hi I have a table which is having datemodified column i need to get only one latest value from the table.Thanks,Gangadhara MSSQL Developer and DBA |
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-02-14 : 03:31:05
|
select max(YourDatemodifiedColumn) from table No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2012-02-14 : 03:31:18
|
select * from tablewhere datemodified =(select max(datemodified) from table)MadhivananFailing to plan is Planning to fail |
 |
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2012-02-14 : 03:39:24
|
Select top 1 * from table order by datemodified descSenthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
 |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2012-02-14 : 09:59:11
|
quote: Originally posted by senthil_nagore Select top 1 * from table order by datemodified descSenthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008
what if you've multiple records for latest date? you want only one of them of all?Select top 1 * from table order by datemodified descSelect top 1 with ties * from table order by datemodified desc ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
X002548
Not Just a Number
15586 Posts |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|