![]() |
|
Archives of the TeradataForumMessage Posted: Tue, 22 Feb 2005 @ 13:17:19 GMT
<-- Anonymously Posted: Tuesday, February 22, 2005 08:09 --> Hi all, Say I have a table with a date and time field in addition to my other fields including trans_id. Those date's and times do not correlate to when a record was inserted, but rather when the event on that line took place. This table is inserted from a feed coming from an AS/400 and records could be in any order. How could I select the record previous to a given trans_id, or the previous 5 records; based on the date and time fields? For example
tableA:
trans_id, trans_date, trans_time
1234, 2005-02-20, 23:15:59
1245, 2005-02-21, 01:23:44
2014, 2005-02-21, 09:19:10
1122, 2005-02-20, 19:35:26
Based on this table, I need to find which record comes before trans_id=1245 based on date/time. Should I sort, apply a sequence number to it and plug it into a volatile table for further querying, or do you have any other suggestions? Much thanks.
| ||||||||||||||||||||||||||||||||||||||||||||||||
| | ||||||||||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||
| Copyright 2016 - All Rights Reserved | ||||||||||||||||||||||||||||||||||||||||||||||||
| Last Modified: 15 Jun 2023 | ||||||||||||||||||||||||||||||||||||||||||||||||