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)
 Query last modified data

Author  Topic 

jai_ts
Starting Member

4 Posts

Posted - 2004-09-23 : 22:12:23
Hi,

How can I query the last modified data that have one unique id but different for others information on the field.

Thanks
Jai

Kristen
Test

22859 Posts

Posted - 2004-09-24 : 04:04:30
Can you clarify the question please?

Kristen
Go to Top of Page

jai_ts
Starting Member

4 Posts

Posted - 2004-09-24 : 04:32:36
here the scenario:-

I have a lot item in my database, every item have unique ID means one of the field is fix, other fields we can change the information, after the modify all the data will save into the database as new data instead updating the current . so if I have modified 5 times, so inside my database I have 6 record for that item,all the record have a modified date. So I want to query the latest record from this 6 records. Thanks in advances.


Thanks,
Jai
Go to Top of Page

Kristen
Test

22859 Posts

Posted - 2004-09-24 : 04:52:32
DO you have a column called "parent" or something similar that gives the ID of the original record?

Can you post a CREATE TABLE statement for the table, and a few INSERT statements for some sample data, then we can see what you are wrestling with.

Kristen
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-09-24 : 05:13:19
will this help:

select top 1 *
from MyTable
order by DateModified desc

Go with the flow & have fun! Else fight the flow
Go to Top of Page

jai_ts
Starting Member

4 Posts

Posted - 2004-09-24 : 05:31:18
Ok guys thanks for helping me, now i got the idea...

I just add one more fields called 'sfx' when the item modified this sfx will increase so I just query the the max number of sfx.

Thanks
Jai
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2004-09-24 : 05:36:53
but that is not needed...
you already have the date column which you can max on

Go with the flow & have fun! Else fight the flow
Go to Top of Page

jai_ts
Starting Member

4 Posts

Posted - 2004-09-24 : 05:49:17
I just tried your query but it's didn't work well, If the item have 2 rows it's work, but when the item have more than 2,lets say 5 rows so when I run the query it's suppose to get the 1st row because we used DESC, but it return row number 4 that's means the 4th latest modified
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2004-09-24 : 05:54:22
give us....
DDL (CREATE STATEMENTS)
INSERT STATEMENTS (SAMPLE DATA)
EXPECTED RESULTS (USING ABOVE)

to move this along faster.
Go to Top of Page
   

- Advertisement -