SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Difference between Dates
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

nokiauk
Starting Member

United Kingdom
9 Posts

Posted - 02/15/2013 :  10:08:53  Show Profile  Reply with Quote
I have the following SQL statement:

SELECT DISTINCT

Loc.Scheme,
Loc.AccessGroup as "Area Office",
Loc.ArrearsOfficeLookup as "Arrears Officer",
TenanT.TenancyRef,
Tenant.TenancyStart,
Tenant.TenancyEnd
-- 'Void_Days' = DATEDIFF(DAY, WHAT GOES HERE)

FROM
[FusionRS_V3].dbo.vwTenancyCurrent AS TenanT
JOIN
[FusionRS_V3].dbo.VwLocationCurrent AS Loc ON TenanT.PlaceRef = Loc.PlaceRef
JOIN
[FusionRS_V3].dbo.vwLocationHistoryCurrent AS LH ON LH.PlaceRef = Loc.PlaceRef
LEFT JOIN
[FusionRS_V3].dbo.vwTenancyAttributesCurrent AS TenAtt ON TenanT.TenancySystemRef = TenAtt.TenancySystemRef
LEFT JOIN
[FusionRS_V3].dbo.vwLocationAttributesCurrent AS LocAtt ON TenanT.PlaceRef = LocAtt.PlaceRef

WHERE

TenanT.TenancyStart BETWEEN '04/01/2011' and '03/31/2012' AND
TenanT.TenancyCat <> 'OCC' AND
LH.LocationStatus = 'V' AND
LH.EndDate >= '04/01/2011' AND
LocAtt.AttributeCode = 'DEM' AND
Loc.PlaceRef = '187AIL006'

ORDER BY

Loc.Scheme

This produces the following:



I need to work out the voids days by taking number of days from the 2nd row Tenancy Start from the 1st row Tenancy End. Is this possible?
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000