<% ' Use vw_warranty_status view which joins machines with warranties table strSQL2 = "SELECT " & _ "COALESCE(SUM(CASE WHEN warrantystatus = 'Active' AND warrantydaysremaining > 90 THEN 1 ELSE 0 END), 0) as active_good, " & _ "COALESCE(SUM(CASE WHEN warrantystatus = 'Active' AND warrantydaysremaining BETWEEN 31 AND 90 THEN 1 ELSE 0 END), 0) as active_warning, " & _ "COALESCE(SUM(CASE WHEN warrantystatus = 'Active' AND warrantydaysremaining <= 30 AND warrantydaysremaining >= 0 THEN 1 ELSE 0 END), 0) as expiring_soon, " & _ "COALESCE(SUM(CASE WHEN warrantystatus = 'Expired' OR warrantydaysremaining < 0 THEN 1 ELSE 0 END), 0) as expired, " & _ "COALESCE(SUM(CASE WHEN warrantystatus IS NULL OR warrantystatus = '' OR warrantystatus = 'Unknown' THEN 1 ELSE 0 END), 0) as unknown, " & _ "COUNT(*) as total " & _ "FROM vw_warranty_status" set rswarranty = objconn.Execute(strSQL2) activeGood = CLng(rswarranty("active_good")) activeWarning = CLng(rswarranty("active_warning")) expiringSoon = CLng(rswarranty("expiring_soon")) expired = CLng(rswarranty("expired")) unknown = CLng(rswarranty("unknown")) total = CLng(rswarranty("total")) If total = 0 Then total = 1 activeGoodPct = FormatNumber(CDbl(activeGood)/CDbl(total)*100,1) activeWarningPct = FormatNumber(CDbl(activeWarning)/CDbl(total)*100,1) expiringSoonPct = FormatNumber(CDbl(expiringSoon)/CDbl(total)*100,1) expiredPct = FormatNumber(CDbl(expired)/CDbl(total)*100,1) unknownPct = FormatNumber(CDbl(unknown)/CDbl(total)*100,1) %>
Warranty Status
<% If unknown > 0 Then %> <% End If %>
Active (>90 days) <%=activeGood%> <%=activeGoodPct%>%
Active (31-90 days) <%=activeWarning%> <%=activeWarningPct%>%
Expiring Soon (<=30 days) <%=expiringSoon%> <%=expiringSoonPct%>%
Expired <%=expired%> <%=expiredPct%>%
Unknown <%=unknown%> <%=unknownPct%>%