Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Yet another 'Group By' question re SET EngineBehavior
Message
 
 
To
13/08/2005 17:31:30
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:
01040732
Views:
23
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.
>
--sb--
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform