General information
Category:
Coding, syntax & commands
>>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only