GROUP BY is intended to GROUP multiple records together so you can calculate MAX(), MIN(), SUM() and similar "aggregate" functions on multiple records and report them in one line.
ORDER BY specifies the ORDER of the resulting recordset.
It's just a confusing coincidence that VFP usually reports records that are GROUPed in the correct order. Don't count on that, as it's not part of the SQL standard to do that, and some data engines don't.
On Thu, Mar 29, 2018 at 11:00 PM, Joe Yoder joe@wheypower.com wrote:
I have an SQL select statement that includes a group by clause to order the output for reporting. It gets its data from a table that potentially includes legitimate duplicate records.
SELECT account, date, memo, paid_amoun; FROM QB; GROUP BY account, date, memo, paid_amoun; INTO CURSOR det
I happened to discover that the output of the select statement does not include duplicate records. Is this expected behavior? If so , how should one group data with duplicate records?
Thanks in advance,
Joe
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]