Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Query to SQL Server on consecutive dates
Message
From
23/11/2004 04:44:01
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00963700
Message ID:
00963742
Views:
8
>Hi,
>
>I have to create a SQL Passthrough in which the WHERE clause filters if the days passed between a date in one record to the date in the previous record are greater than let say 10 days, within a specific grouping of records.
>
>Any ideas?
>
>
>Thanks, J

Assuming you decide previous, next record based on dates:
select distinct a.myDate as FirstDate, b.myDate as NextDate, 
  days = DateDiff(day,a.myDate, b.myDate)
  from myDates a inner join mydates b
  On b.myDate = (Select Min(myDate) from myDates c where c.myDate > a.myDate)
  where DateDiff(day,a.myDate, b.myDate) > 10
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform