Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL Server puzzle
Message
From
12/06/2011 01:08:24
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01514149
Message ID:
01514163
Views:
50
Interesting, the queries are almost identical, but the first takes 71% in the execution plan...

Not sure I understand what you mean by the 71%.

Actually they're somewhat different. (They both certainly work).

Yours was using the OVER statement, which winds up creating a table spool. If you look at the IO statistics, yours has the extra worktable, though both our subsequent # of reads for the 2 tables are the same.


Actually, a subquery isn't necessary, this could have been done with a simple JOIN - I used one simply to materialize the line item ratio as a column and then use it to multiply to the freight, as opposed to repeating the same expression twice.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform