Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to return group total by shortest item
Message
 
 
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01331819
Message ID:
01331908
Vues:
9
What made you doubt that? <bg>

>Sergey, you're still a SQL-genius. Thanks!
>
>
>>John,
>>
>>Try
>>
>>SELECT ig.ItemGroup, SUM(Cost) AS SumCost
>>	FROM ( SELECT Item AS ItemGroup FROM po p1
>>			WHERE NOT EXISTS ( SELECT 1 FROM po
>>				WHERE p1.Item <> Item AND p1.Item LIKE Item + '%')
>>		) ig JOIN po ON po.Item LIKE ig.ItemGroup + '%'
>>	GROUP BY ig.ItemGroup
>>
>>
>>>
>>>I keep thinking there should be an easy way to query for what I need but just can't come up with anything so here it goes.
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform