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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 need to fetch latest record from a table

Author  Topic 

shekhar_dba
Starting Member

39 Posts

Posted - 2006-10-19 : 14:57:08
Hi gurus....

i wanna to fetch a record that is latest in the table.column contain date and time and i have to fetch a resord that is with latest time and it should be distinct. please help me out of this

thanks
shekhar

mfemenel
Professor Frink

1421 Posts

Posted - 2006-10-19 : 15:04:15
select top 1 * from table name order by datecol desc, timecol desc

Mike
"oh, that monkey is going to pay"
Go to Top of Page

shekhar_dba
Starting Member

39 Posts

Posted - 2006-10-19 : 15:16:13
hi

actually i have one column for date&time both.so please rifine it little to let me understand better
thanks
shekhar

quote:
Originally posted by mfemenel

select top 1 * from table name order by datecol desc, timecol desc

Mike
"oh, that monkey is going to pay"

Go to Top of Page

mfemenel
Professor Frink

1421 Posts

Posted - 2006-10-19 : 15:24:08
Come on man. Just use that column name desc instead of the two I put in there. You have to put some effort in here!

Mike
"oh, that monkey is going to pay"
Go to Top of Page

Sitka
Aged Yak Warrior

571 Posts

Posted - 2006-10-19 : 15:27:18
Perhaps a little Socrates can help.

Which is sooner?

'2006-10-19 15:23:09.823'
OR
'2006-10-19 15:23:48.840'


My own view of the purpose of the Socratic Method is that it prepares people to think. The only people who are incapable of thinking about an issue are those who are already convinced they have “the” understanding of an issue. In my view, there are no “Socratic teachings.” But there is a Socratic goal. The goal inherent in any method of questioning that I would call “Socratic” is the improvement of the soul (i.e. human consciousness). The Socratic Method deconstructs people’s understanding using their own words and leaves them with the experience of being less sure of what they previously knew with greater certainty. This is its value. You might consider changing your nickname.

sniped



"it's definitely useless and maybe harmful".
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-10-20 : 12:33:46
quote:
Originally posted by shekhar_dba

Hi gurus....

i wanna to fetch a record that is latest in the table.column contain date and time and i have to fetch a resord that is with latest time and it should be distinct. please help me out of this

thanks
shekhar


Still you dont get it, Post some sample data and the result you want

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -