Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to return group total by shortest item
Message
 
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
01331819
Message ID:
01331908
Views:
8
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--
Previous
Reply
Map
View

Click here to load this message in the networking platform