Viewing 10 posts - 1 through 11 (of 11 total)
Ninja's_RGR'us (11/21/2011)
use master ;
;
WITH CTE ( object_id, summ )
AS (
...
November 21, 2011 at 11:48 am
I still want to learn on my own as always try to do. I searched for efficiency tests about the order by, max(), and so on. but nothing. Since you...
November 21, 2011 at 11:44 am
Ninja's_RGR'us (11/21/2011)
GilaMonster (11/21/2011)
November 21, 2011 at 11:25 am
Matt Miller (#4) (11/21/2011)
Ninja's_RGR'us (11/21/2011)
bomborde (11/21/2011)
Revenant (11/21/2011)
ScottPletcher (11/21/2011)
SELECT TOP 1 Name, SUM(Consumption) AS Total_Consumption
FROM tablename
GROUP...
November 21, 2011 at 10:44 am
ScottPletcher (11/21/2011)
This does not work if two or more people have the same total.
To paraphrase Clinton, it depends on the definition of "work". If two people have the same...
November 21, 2011 at 10:41 am
Revenant (11/21/2011)
ScottPletcher (11/21/2011)
Don't see how you can do this w/o an ORDER BY, but it's trivial with one:
SELECT TOP 1 Name, SUM(Consumption) AS Total_Consumption
FROM tablename
GROUP BY Name
ORDER BY SUM(Consumption) DESC
This...
November 21, 2011 at 10:27 am
Ninja's_RGR'us (11/21/2011)
Lookup cross & outer apply.
Thanks!
November 21, 2011 at 10:02 am
GilaMonster (11/21/2011)
bomborde (11/21/2011)
An order will be inefficient because it will order the whole table.
Do you know that or are you guessing? The entire table has to be retrieved and hashed...
November 21, 2011 at 9:56 am
GSquared (11/21/2011)
Is it a homework/test/interview type question, where artificial constraints...
November 21, 2011 at 9:50 am
An order will be inefficient because it will order the whole table. I dont want this. (imagine a table with 500k tuples). I just want the maximum.
November 21, 2011 at 9:48 am
Viewing 10 posts - 1 through 11 (of 11 total)