I've tried to explain as best I can...
I currently have two peices of code:
Code:
SELECT First(HighLevelCapacity.Used) AS StartDateUsed, Last(HighLevelCapacity.Used) AS EndDateUsed, First(HighLevelCapacity.Total) AS StartDateTotal, Last(HighLevelCapacity.Total) AS EndDateTotal, StartDateTotal-StartDateUsed AS StartDateFree, EndDateTotal-EndDateUsed AS EndDateFree, (StartDateUsed/StartDateTotal)*100 AS StartDatePercentage, (EndDateUsed/EndDateTotal)*100 AS EndDatePercentage, StartDateUsed-EndDateUsed AS UsedDiff, StartDateTotal-EndDateTotal AS TotalDiff, EndDateFree-StartDateFree AS FreeDiff, StartDatePercentage-EndDatePercentage AS PercentageDiff, First(HighLevelCapacity.Date) AS StartDate, Last(HighLevelCapacity.Date) AS EndDate
FROM HighLevelCapacity
WHERE (((HighLevelCapacity.SANName)="Server1") AND ((HighLevelCapacity.AggregateName)="Aggregate1")) AND ((HighLevelCapacity.Date) Between (Forms!ReportDataRangeSelect!SelectStart) And (Forms!ReportDataRangeSelect!SelectEnd));
Code:
SELECT TOP 1 HighLevelCapacity.SANName, HighLevelCapacity.AggregateName, Int(Round(([Query1].StartDateUsed)/1024^2,1)) AS FirstUsedGB, Int(Round(([Query1].EndDateUsed)/1024^2,1)) AS LastUsedGB, Int(Round(([Query1].StartDateTotal)/1024^2,1)) AS FirstTotalGB, Int(Round(([Query1].EndDateTotal)/1024^2,1)) AS LastTotalGB, Int(Round(([Query1].StartDateFree)/1024^2,1)) AS FirstFreeGB, Int(Round(([Query1].EndDateFree)/1024^2,1)) AS LastFreeGB, Int(Round([Query1].StartDatePercentage,1)) AS FirstPercentage, Int(Round([Query1].EndDatePercentage,1)) AS LastPercentage, FirstUsedGB-LastUsedGB AS UsedDiff, FirstTotalGB-LastTotalGB AS TotalDiff, FirstFreeGB-LastFreeGB AS FreeDiff, FirstPercentage-LastPercentage AS PercentageDiff, DateDiff("d",(Forms![ReportDataRangeSelect]![SelectStart]),(Forms![ReportDataRangeSelect]![SelectEnd])) AS DateDiff, Int(Round((UsedDiff)/(DateDiff),1)) AS DailyIncreaseGB, IIf([DailyIncreaseGB]=0,'No Change',IIf([DailyIncreaseGB]>0,'Decrease',INT(Round(LastFreeGB/IIf(DailyIncreaseGB=0,'Null',DailyIncreaseGB),1)))) AS TimeLeft
FROM Query1, HighLevelCapacity
WHERE (((HighLevelCapacity.SANName)="Server1") AND ((HighLevelCapacity.AggregateName)="Aggregate1"));
Now the code is written, I just need to replicate it for the relevant servers. So the code will stay exactly the same, and only the text in Red will change (depending on what server/aggregate combination it is, and what the name of the first query is saved as). The combinations will be...
Server1 - Aggregate1
Server1 - Aggregate2
Server1 - Aggregate3
Server1 - Aggregate4
Server2 - Aggregate1
Server2 - Aggregate2
And so on and so forth.... For each combination, it will need the above two queries; and obviously the query1 name in the code will have to be changed every time. Doing this for 4 servers, actually only means about 30 queries, so isn't that time constrainting, but I soon have to do it with a further 45 different combinations. So if I can learn how to do it on this, i'm hoping to be able to adapt it to that afterwards.
Hope that explains things a little better?
Pbaldy - apologies, the link doesnt make much sense to me.
Thanks