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
 Transact-SQL (2000)
 Comparing datetime between two tables

Author  Topic 

Chris Orlando
Starting Member

9 Posts

Posted - 2005-08-02 : 10:58:28
Table 1:
ID (Identity), Event Time, Price, Symbol
1, 9:15AM, $2, X
2, 9:20AM, 2.50, X
3, 9:25AM, 2.25, X

Table 2:
Event Time, Price a, Price b, Symbol
9:14AM, $2.01, $2.30, x
9:15AM, $2.01, $2.34, x
9:16AM, $2.01, $2.45, x


I have to find all PREVIOUS record (Event_Time) of the x record in table 2 where the price in table 1 is less than price a OR greater than price b.

Any ideas? 4 million rows per table, 800 different symbols...
Finding the previous Event time record in the other table is where I am having problems.

thanks for your help...

TG
Master Smack Fu Yak Hacker

6065 Posts

Posted - 2005-08-02 : 13:50:26
Sorry Chris, I'm not clear on what you need. could you please post the DDL of both tables, DML for some sample data for maybe 2 different symbols, and the expected results of the query?

(DDL: script to create your tables
DML: insert statements so we can populate your tables with sample data)

Be One with the Optimizer
TG
Go to Top of Page
   

- Advertisement -