Nancy,
Try this:
;WITH DBSnapshots AS (
SELECT DBName,
Min(postdate) as OldestGatherDate,
Max(postDate) as NewestGatherDate
FROM DBGrowthRate
GROUP BY DBName
)
SELECT
s.DBName,
d1.CurSize as OriginalSize
d1.Gatherdate as OldestGatherdate
d2.CurSize as CurrentSize
d2.Gatherdate as NewestGatherdate
FROM DBSnapshots s
JOIN DBGrowthRate d1 ON s.dbname = d1.dbname
AND s.OldestGatherDate = d1.Gatherdate
JOIN DBGrowthRate d2 ON s.dbname = d2.dbname
AND s.NewestGatherDate = d2.Gatherdate
No comments:
Post a Comment