Get the smallest timespan between two entries
From: mike (mike_at_discussions.microsoft.com)
Date: 10/27/04
- Next message: Becky Brock via SQLMonster.com: "SQL Server Query Analyzer Does Not Open"
- Previous message: news.microsoft.com: "Re: Sum a Union Query"
- Next in thread: Hugo Kornelis: "Re: Get the smallest timespan between two entries"
- Reply: Hugo Kornelis: "Re: Get the smallest timespan between two entries"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 27 Oct 2004 03:49:07 -0700
Hi all,
we have a table with a column of type "datetime"
We want to get the smallest timespan between two entries.
Now we get this timespan with the following query (it works but it's to
slow, it runs 5 secs with 250000 entries):
select min(Datediff(minute,a.rectime,b.rectime))
from dbo.value a, dbo.value b
where b.rectime = ( select min(rectime) from dbo.value
where rectime > a.rectime )
Any idea? Thanks in advance,
Mike
- Next message: Becky Brock via SQLMonster.com: "SQL Server Query Analyzer Does Not Open"
- Previous message: news.microsoft.com: "Re: Sum a Union Query"
- Next in thread: Hugo Kornelis: "Re: Get the smallest timespan between two entries"
- Reply: Hugo Kornelis: "Re: Get the smallest timespan between two entries"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|
|