Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Need to perform calculation with the previous record
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
00537434
Message ID:
00537549
Vues:
11
>It's easier if you were sure that there was a record for each date:
>
>SELECT
> a.item,
> a.date,
> a.value,
> b.date,
> b.value
>FROM
> thetable a
> INNER JOIN thetable b ON b.date = a.date + 1
>WHERE
> ABS((a.value / b.value) - 1) > .5
>
>-Mike

It is not sure that I have price for every day (saturdays and sundays are not there for sure).

But I haven't of JOIN. I think that I can do something like:
INNER JOIN thetable b ON b.date = (select min(date) ... where c.date > a.date )

Can this be good?
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform