January 16, 2008 at 7:30 am
technically there is no need, it was just for demonstration purposes 🙂
Did you have a look at the execution plans? It did look like it was more optimal to go the CTE/derived table route, I need to do some testing with larger datasets and a more intensive sub query though
January 16, 2008 at 7:49 am
Heh... understood and thanks...
Becareful, though, Sam... one of the things that an Execution Plan will do, is "lie"... frequently, it can't "see" past the first row of the correlated sub-query (whatever form it takes) and will report seeming remarkable low percentages... the best proof of the pudding is an actual run on something like a million rows with STATISTICS IO and STATISTICS TIME turned on.
For the record, I think you'll find that the actual performance of a single use CTE is no better than a Derived Table... in my (so far) limited experience with 2k5, I've found that they are basically the same thing... CTE just allows more multiple references in the SELECT than a derived table and can be self joined for recurrsion (my least favorite form of RBAR). 😛
--Jeff Moden
Change is inevitable... Change for the better is not.
June 2, 2009 at 3:26 pm
Is it possible to add up the results from the case statments? I am trying to get the total time for a person, plus double time for working the midnight shifts.
June 2, 2009 at 9:47 pm
Absolutely. You can use CASE in just about any of the aggregate fuctions like SUM, etc.
--Jeff Moden
Change is inevitable... Change for the better is not.
June 3, 2009 at 8:07 am
I haven't had much luck with the case statements.
I have renamed the cases at M1 and M2. when ever I try to use the case names I get an 'invalid column name'. I have changed the case from 'end as M1' to 'M1 = case' and still get the same results.
If any has any ideas, it would be a great help. I can see all the raw data is correct and just need to do a couple of sum statements to finish this project off.
TIA
Viewing 5 posts - 16 through 19 (of 19 total)
You must be logged in to reply to this topic. Login to reply