Friday, January 28, 2011

TSQL- Finding the differene in days of multiple records

Programmer Question

Is it possible to find the difference of days of different records in SQL Server 2008 R2?



SELECT OrderDate FROM OrdersTbl WHERE SKU='AA0000' ORDER BY ORDERDATE DESC


OrderDate
-----------------------
2009-12-03 00:00:00.000
2009-04-03 00:00:00.000
2008-02-22 00:00:00.000
2008-02-21 00:00:00.000
2007-02-18 00:00:00.000
2007-01-27 00:00:00.000
2006-10-13 00:00:00.000


I would like a way to get how many days in between there are for each order date so that I could find the average frequency. Thanks in advance.



Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails