Re: Grouping by datepart() affected fields >> (i want to be able to group by months <<
Why did you try a computational approach at all? Try this data-driven
approach:
CREATE TABLE ReportRanges
(report_name CHAR(10) NOT NULL PRIMARY KEY,
start_date DATETIME NOT NULL,
end_date DATETIME NOT NULL,
CHECK (start_date < end_date),
range_type CHAR(2) DEFAULT 'mn' NOT NULL
CHECK (range_type IN ('DY', 'MN', 'YR', ..));
Now use predicates like " my_date BETWEEN start_date AND end_date" to
get your groups. You can use indexes and paralellism, the code will
port yo any SQL, etc. |