Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Query to SQL Server on consecutive dates
Message
De
23/11/2004 04:44:01
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00963700
Message ID:
00963742
Vues:
7
>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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform