first after looking at all , i wonder if dl_date in the table should not be date function or form field
i have optimized the switch from jun7 (perfect option)
i have changed 1 dl_date lower then the last_issue2
Code:
SELECT
STOCK_NO,
LAST_ISSUE2,
DL_DATE,
DL_DATE-LAST_ISSUE2 AS TSLI,
TSLI/365 AS TSLIyr,
Switch(
TSLIyr >= 5,5,
TSLIyr >= 3, 4,
TSLIyr >= 2, 3,
TSLIyr >= 1,2,
TSLIyr >= 0,1,
isnull(TSLIyr),-1,
True, 0) AS rng
FROM ISSUE_DATA ;
Code:
SELECT Switch(
rng = 5, "5 to 10",
rng = 4, "3 to 4.999",
rng = 3, "2 to 2.999",
rng = 2, "1 to 1.999",
rng = 1, "0 to 0.999",
rng = 0," ???",
true,"null") & " yrs" AS rang, Count(*) AS CountOfTSLIyr
FROM grouping
where rng < 6
GROUP BY rng ;