Thanks for the replies.
Yes, this is SQL Server. I knew about the Query Analyzer and the execution path and all that, but was curious as to whether or not there's a better method for querying out data in the manner which I described.
Yeah, THIS report could definitely be redesigned (I'll prob. have a talk w/ my project manager about), but there are times when I had to do ONLY 2 or 3 columns of summed up data.
I've always sat back and wondered if it was good practice or not to query data like that.. basically doing the:
select field1, field2= (SELECT SUM(Amount) FROM tbl WHERE x=1), field3 = (SELECT SUM(Amount) FROM tbl WHERE x=2) from tbl ... etc
Another question I have for you, twister, is that you mentioned I should use a view. I've always used stored procs for EVERYTHING: inserting, updating, and selecting. How does a view differ from a stored proc? I've always used a view as a visual query designer of sorts, then took the SQL it made and copied & pasted to a stored proc. I know you can select FROM a view, but I'm unaware of any advantages it has to offer over stored procs.
__________________
I love lamp.
|