April 2, 2012 at 5:48 pm
Both work, but yes, improved.....now I just need to spend the time to figure it all out....:-)
BTW, it works perfect on my 20,000 + rows, took 7 seconds total.....
Is there any way to replace the null values with a space?
April 2, 2012 at 6:53 pm
Heh... I just knew that would be the next question and I should have done that to begin with.
SELECT PIN = ISNULL(PIN,''),
CDate = ISNULL(CDate,''),
BTN = ISNULL(BTN,''),
Descr = ISNULL(Descr,''),
CallCount,
CallDuration,
Charge
FROM
(
SELECT PIN,
CDate = CASE WHEN GROUPING(PIN) = 0 THEN 'SubTotal' ELSE 'Total' END,
BTN = NULL,
Descr = NULL,
CallCount = SUM(CallCount),
CallDuration = SUM(CallDuration),
Charge = SUM(Charge)
FROM #GMReport
GROUP BY PIN WITH ROLLUP
UNION ALL
SELECT PIN, CDate, BTN, Descr, CallCount, CallDuration, Charge
FROM #GMReport
)d
ORDER BY ISNULL(PIN,'Z'), CDate, BTN
;
--Jeff Moden
Change is inevitable... Change for the better is not.
April 2, 2012 at 7:02 pm
gmcnitt (4/2/2012)
Both work, but yes, improved.....now I just need to spend the time to figure it all out....:-)BTW, it works perfect on my 20,000 + rows, took 7 seconds total.....
Is there any way to replace the null values with a space?
Just curious... that included the time to output to the screen? If so, grid mode or text mode?
The reason I ask is because that just seems awfully slow to me.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 2, 2012 at 8:45 pm
Output to grid, and I am using a view that includes around 48 individual tables...
April 3, 2012 at 5:39 am
Ah... the VIEW might explain it. It's actually being executed twice if you're using it directly in the code I wrote. You'll get much better performance if you do a SELECT/INTO a temp table and point my code at the temp table because the view will only need to execute once that way. Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
April 3, 2012 at 9:15 am
Yes, thats what I did, the select into the temp table is what takes the time, running the query on the temp table is milli seconds......thanks again, still awaiting the users input, but I think its exactly what the doctor ordered.
April 3, 2012 at 11:33 am
You bet. Thank you for the thoughtful feedback. Really appreciate it.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 7 posts - 16 through 21 (of 21 total)
You must be logged in to reply to this topic. Login to reply