Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Create Select Group By (on huge table)
Message
De
28/09/2005 10:48:14
 
 
À
27/09/2005 21:37:07
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Autre
Divers
Thread ID:
01053729
Message ID:
01053958
Vues:
11
>My table fields are...
>cClass
>cSku
>cSupplier
>cStyle
>cCost
>cRetail
>nSalesQty
>
>Table has 23 millions of records, then I need to create the best query. My query needs all fields in SELECT... a SUM on nSalesQty and GROUP BY cClass and cSku. My question is: how can I extract in the same query (or otherwise) all the rest of fields (cSupplier, cStyle, cCost, cRetail), because other fields are not aggregate. Do I need to use MAX(cSupplier), MAX(cStyle)... etc ? Or there is another way to do that? Don't forget my table is very huge.
SELECT *,GG.SUMX FROM TABLE TT
JOIN (SELECT SUM(nSalesQty),MIN(pk) minpk SUMX FROM TABLE GROUP BY cClass,cSku) GG 
ON TT.pk=GG.minpk
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform