Hi I am receiving the following error:Server: Msg 8624, Level 16, State 3, Line 3Internal SQL Server error.When I run the following query (see below), I receive this error. However, if I comment out line 32: --WHERE center = t1.center AND tsr = t1.tsr AND appl = t1.appl AND listid = t1.listid
The code runs fine. However, I need to reference the alias from the derived table (t1) in this portion of the subquery. Is this a known bug for MS SQL 7.00.961 (sp 3?) ?USE REPORTINGGODECLARE @daysback INTSET @daysback = 10SELECT t0.center, t0.tsr, t0.appl, t0.listid, SUM(CAST((t0.time_connect + t0.time_paused + t0.time_waiting + t0.time_deassigned + t0.time_acw) AS DECIMAL(9,2)) / 3600.0) AS sum_totaltime, SUM(CAST(t0.time_connect AS DECIMAL(9,2)) / 3600.0) AS sum_connect, SUM(CAST(t0.time_paused AS DECIMAL(9,2)) / 3600.0) AS sum_paused, SUM(CAST(t0.time_waiting AS DECIMAL(9,2)) / 3600.0) AS sum_waiting, SUM(CAST(t0.time_deassigned AS DECIMAL(9,2)) / 3600.0) AS sum_deassigned, SUM(CAST(t0.time_acw AS DECIMAL(9,2)) / 3600.0) AS sum_acwFROM tsktsrhst t0 CROSS JOIN ( SELECT center, tsr, appl, listid, call_date, CAST((time_connect + time_paused + time_waiting + time_deassigned + time_acw) AS DECIMAL(9,2)) / 3600.0 total_hours FROM tsktsrhst WHERE call_date >= (GETDATE() - @daysback) ) t1 WHERE t0.center = t1.center AND t0.tsr = t1.tsr AND t0.appl = t1.appl AND t0.listid = t1.listid AND t0.call_date >= (GETDATE() - @daysback) AND --MAY BE REDUNDANT, JUST WANT TO TRIM RESULT SET t1.call_date <= t0.call_date --FOR CUMMULATIVE AGGREGATE, REFERENCED IN CROSS JOIN --FOR SLIDING AGGREGATE, REFERENCED IN CROSS JOIN. AND t1.call_date BETWEEN ( SELECT MIN(call_date) min_call_date FROM ( SELECT TOP 50 call_date FROM tsktsrhst WHERE center = t1.center AND tsr = t1.tsr AND appl = t1.appl AND listid = t1.listid ORDER BY call_date DESC ) t2 ) AND ( SELECT MAX(call_date) max_call_date FROM tsktsrhst WHERE center = t1.center AND tsr = t1.tsr AND appl = t1.appl AND listid = t1.listid ) GROUP BY t0.center, t0.tsr, t0.appl, t0.listidORDER BY t0.center, t0.tsr, t0.appl, t0.listid
Thanks,dKK