Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Yet another 'Group By' question re SET EngineBehavior
Message
From
13/08/2005 17:56:07
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows XP SP1
Miscellaneous
Thread ID:
01040687
Message ID:
01040737
Views:
23
Does it? I mean, if there is a field Orders.Partno, and there are records for one OrdNbr that have different PartNos, won't those still come out as distinct records?

Jim

>If you don't have memo fileds in the table, following should work
>SELECT DIST * FROM (
>  SELECT Orders.*, tot.TOTAMT ;
>    FROM Orders ;
>      JOIN (SELECT OrdNbr, SUM(AMT) AS TOTAMT FROM Orders GROUP BY OrdNbr) tot ;
>    ON tot.OrdNbr = Orders.OrdNbr
>) dt1
>
>
>
>
>>
>>Unfortunately, I don't seem to be getting the results I expect. I still get one record for every original record I selected from "Orders", with the total column added at the end.
>>
>>What I'm looking for, and get with 70, is that I get one record for each unique OrdNbr in "Orders", with the total column added at the end. Thus, I get the same number or records as you obtained within your sub-query. It looks like the JOIN you suggested each of the records from my original table with the single row from the sub-query; I want one row (and I don't care which one) from the original table for each row in the sub-query.
>>
Jim Nelson
Newbury Park, CA
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform