I think this can help you :
select no, calving_date, calving_date-lag(calving_date, 1) over(order by calving_date)
from t
order by 2
Laly
Extranet
[Email Address Removed] - 27/11/2003 16:06
Pour : oracledba
cc :
Objet : Urgent: SQL_Query:how to find inter calving period in days
Hi all,
I have table with data inside;
no calving date
---- ------------
1 10-jan-2001
2 11-feb-2002
3 08-jan-2003
I'm looking for querry which will return
no calving date inter calving period in day
---- ------------ ---------------------------
1 10-jan-2001 0
2 11-jan-2002 366
3 10-jan-2003 365
here is example how should it be;
no calving date inter calving period in days
---- ------------ ---------------------------
1 10-jan-2001 0 first row it
should be ZERO
2 11-jan-2002 366 no of days between second
calving date and first calving date i.e no of days between 11-jan-2002
and 10-jan-2001
3 10-jan-2003 365 no of days between third
calving date and second calving date i.e no of days between 10-jan-2003
and 11-jan-2002
Thanks &Regards,
Harik
--------
Get today's cartoon: http://www.LazyDBA.com
Please don't reply to RTFM questions
Oracle documentation is here: http://tahiti.oracle.com
To unsubscribe: send a blank email to oracledba-[Email Address Removed] subscribe: send a blank email to oracledba-[Email Address Removed] using this list you agree to these terms:
http://www.lazydba.com/legal.html
This message and any attachments (the "message") is intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole or partial, is prohibited except formal approval.
The internet can not guarantee the integrity of this message. BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
---------------------------------------------
Ce message et toutes les pieces jointes (ci-apres le "message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.
Oracle LazyDBA home page