Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL - Difference between ORDER and GROUP
Message
From
13/09/1999 12:25:59
Peter Brama
West Pointe Enterprises
Detroit, Michigan, United States
 
 
To
13/09/1999 12:19:52
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00264016
Message ID:
00264049
Views:
28
Sylvain

So the group by is the same as a grouping clause in a report. The only difference is that it does the grouping with the records PRIOR to the report and this, the detail of the report would be JUST the grouped records and not the individual ones that make it up.

If that is the case, if I want the detail as well as group footers with totals, I would NOT use the GROUP BY in the select but instead use a DATA GROUPING in the report to catch the totals in the header.


Correct?


>>What is the difference between ORDER BY and GROUP BY?
>
>Hi Peter,
>
>As Pete said, ORDER BY should be enough for you, but I'll give an example of GROUP BY, if you don't mind.
>
>Let's assume the following simple table, which would be the child table of an invoice:
>
>
>InvNo         Amount
>--------------------
>0001          120.00
>0002           40.00
>0001           15.00
>0001           10.00
>0002           20.00
>
>
>GROUP BY will usually be used with a function such as SUM(). For example, if what you want is the total for each invoice, SELECT InvNo, SUM(Amount) AS Total FROM InvDetail GROUP BY InvNo would return:
>
>
>InvNo      Total
>----------------
>0001      145.00
>0002       60.00
>
>
>I hope this clears things up a little!
Peter Brama
West Pointe Enterprises

VFP is getting easier but STILL alot to learn!!
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform