Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
GROUP BY 1 no longer works
Message
From
17/02/2003 10:28:01
 
 
To
16/02/2003 18:34:58
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
00750415
Message ID:
00754099
Views:
47
>That there were problems in prior VFPx releases in this area (incorrect results of DISTINCT and incomplete GROUP BY).

These are simple to see. I'm writing this off the top of my head, so the code is untested, but here's the gist.

First, for DISTINCT:
CREATE CURSOR HasMemo1 (iFK I, mNotes M)
INSERT INTO HasMemo VALUES (1, "This is the first note")
INSERT INTO HasMemo VALUES (2, "This is the second note")

CREATE CURSOR HasMemo2 (iFK I, mNotes M)
INSERT INTO HasMemo VALUES (1, "This is a different note")
INSERT INTO HasMemo VALUES (2, "So is this")

SELECT * FROM HasMemo1 ;
UNION ;
SELECT * FROM HasMemo2 ;
INTO CURSOR Result
You get only two records in the result, not four, because the memos aren't compared.

For GROUP BY, consider this one:
OPEN DATABASE HOME(2)+"TasTrade\Data\TasTrade"
SELECT customer_id, MAX(order_date), freight ;
   FROM orders ;
   GROUP BY 1 ;
   INTO CURSOR result
The values for Freight don't match up with the most recent order.

Tamar
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform