Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SELE .... UNION problem
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
00846041
Message ID:
00846046
Vues:
22
This message has been marked as the solution to the initial question of the thread.
Randy,

The ORDER BY clause can only by applied to the whole select (result of UNION) not to each individual SELECT. You can get the same result w/o UNION also.
SELECT "1" AS so, *  FROM bondmat ;
	WHERE stores  ;
	UNION ALL ;
		SELECT "2" AS so, *  FROM bondmat ;
		WHERE .NOT.stores  
        ORDER BY part_no ;
	INTO TABLE rcursor
* W/o UNION
SELECT IIF(stores, "1", "2") AS so, *  ;
        FROM bondmat ;
        ORDER BY part_no ;
	INTO TABLE rcursor
>Hello All,
>
>Using VFP7 SP1. In an attempt to build a report cursor, I wrote the following SQL SELECT statement: (bondmat is C10, stores is L1)
>
>SELECT "1" AS so, *  FROM bondmat ;
>	WHERE stores  ORDER BY part_no ;
>	UNION ALL ;
>		SELECT "2" AS so, *  FROM bondmat ;
>		WHERE .NOT.stores  ORDER BY part_no ;
>	INTO TABLE rcursor
>
>The two halves work fine independently of each other, but the attempt to 'stik'em' together gives me the message 'Order By clause is invalid'.
>
>The easy out for this situation was to add a new index to the table, but I'm still curious about what I did wrong in the SELECT.
>
>Thanks,
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform