Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Very Complex SQL - My Brain Hurts
Message
 
 
À
06/07/2006 13:31:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Versions des environnements
Visual FoxPro:
VFP 7 SP1
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01133780
Message ID:
01134261
Vues:
18
This message has been marked as the solution to the initial question of the thread.
SELECT Operator, Route, Class, ;
	SUM(IIF(BETWEEN(etmdate, ldStart1, ldEnd1), Notickets, 0000000000)) AS Passengers1, ;
	SUM(IIF(BETWEEN(etmdate, ldStart2, ldEnd2), Notickets, 0000000000)) AS Passengers2 ;
FROM ETMData ;
WHERE etmdate BETWEEN ldStart1 and ldEnd1 OR etmdate BETWEEN ldStart2 and ldEnd2 ;
GROUP BY Operator, Route, Class ;
INTO CURSOR crsPassengers

SELECT ps.*, ... FROM crsPassengers ps ;
  JOIN OperatorClass oc ON oc.Operator = ps.Operator AND oc.Class = ps.Class ;
INTO CURSOR crsStep2
>Good news, Sergey. the first "hit" of the SQL seems to be working just fine, thanks.
>
>By "join" do you mean doing an SQL UNION? Only, don't the 2 tables to be unioned need to have an identical layout.
>
>I've joined identically laid out, say, results tables together, to form a mega table but I've never joined them to "merge" them, appending more fields to the first, and work out a calculation on the merged data (e.g. passenger nos * multiplier). Iguess y SQL just hasn't had to do this as yet.
>
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform