Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
GROUP BY 1 no longer works
Message
De
17/02/2003 10:28:01
 
 
À
16/02/2003 18:34:58
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00750415
Message ID:
00754099
Vues:
43
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform