|Do you know where your variables are?|
Re^2: find difference in dates/items in same columnby zerocred (Beadle)
|on Nov 14, 2008 at 18:48 UTC||Need Help??|
oopps error in the earlier code I accidentally poseted while not logged in.
I tried the techniques here:
it looks like this:
This does work like you say by creating the T and T1 alias/copy tables then you line up the sequence numbers (rank1 and rank2) and process the columns of interest.
The problem is it takes about 1 hour to return the query on about 120,000 records... Even merely sequencing the brands alone (the inner Select count(*) part) takes about 7 minutes). I think teh SQL is slow because the whole table is searched each time to find the next in sequence. By using my perl program and executing the Select to return the table in the sorted order you know the next record is the one you are looking for. It runs in about 30secs -1min onthe same table.
When I started out looking to solve this problem I thought it would be a relatively easy piece of SQL to solve a very common problem, e.g. calculate the time between time stamps in a log file for example. But in SQL it seems not;)