Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SQL
Message
 
To
08/02/2000 17:41:22
Dragan Nedeljkovich (Online)
Now officially retired
Zrenjanin, Serbia
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Re: SQL
Miscellaneous
Thread ID:
00328952
Message ID:
00329218
Views:
23
>>2) Any fields not involved in a sum, must be included in the group by clause.
>>
>>A simple example:
>>
>>Select name, address, city, zip, sum(bill) as bill from mytable ;
>> group by name, address, city, zip ;
>> into cursor mycursor
>>
>>Name,address, city, zip are all in the group by because they are not being summed.
>
>Not necessarily so. We may simply group by zip if we wanted a 'per city' total. Of course, that would make the name and address fields meaningless. Depends on what we want.
>
If a field is not in the group by clause, and isn't selected in an aggregate function, it will select the field from the last record in the group (in record number order) which is sometimes desirable. It is equivalent to the Last() aggregate function in Access, which does require all fields to be either in the group by, or in an aggregate function, or used in an expression. Access therefore provides more aggregate functions.
Previous
Reply
Map
View

Click here to load this message in the networking platform