Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
nokiauk
Starting Member
9 Posts |
Posted - 2013-02-15 : 10:08:53
|
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.PlaceRefWHERETenanT.TenancyStart BETWEEN '04/01/2011' and '03/31/2012' ANDTenanT.TenancyCat <> 'OCC' ANDLH.LocationStatus = 'V' ANDLH.EndDate >= '04/01/2011' ANDLocAtt.AttributeCode = 'DEM' ANDLoc.PlaceRef = '187AIL006'ORDER BYLoc.SchemeThis 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? |
|
|
|
|