Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select with GROUP BY - much slower than without
Message
 
 
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 9
Divers
Thread ID:
01110065
Message ID:
01110285
Vues:
19
What about
SELECT * FROM cursor1
UNION 
SELECT * FROM cursor2
BTW, I don't think you need ';' in the textmerge SQL SELECT.

>
>In the Trans_Employee_Queues we have a field cCommission_Owner_UsGrLink_fk, which points to a commissioned owner of the account (in other words, to the user who is working on this account). The accounts could be also assigned on the temporary basis, in this case the cUsGrLink_fk field is used (the name is a little bit misleading, the better name would be cTemp_Owner_UsGrLink_fk).
>
>In 99% of the cases accounts are assigned on the permanent basis.
>
>Here is how I'm trying to re-write my statements right now:
>
>
>text TO lcSQLStr NOSHOW TEXTMERGE PRETEXT 7
>	SELECT Trans.cTrans_pk, Usgrlink.cUsGrlink_pk, ;
>		Users.cUserID, Trans.yCurrent_balance_amount ;
>	FROM TRANS INNER JOIN Trans_employees_queues ;
>	ON Trans.cTrans_pk = Trans_employees_queues.cTrans_fk ;
>	INNER JOIN UsGrLink ON ;
>	Trans_employees_queues.cCommission_Owner_UsGrLink_fk = UsGrLink.cUsGrLink_pk ;
>	INNER JOIN USERS ON Users.iID = Usgrlink.iUserID ;
>	INNER JOIN Employee_queue_schedules ;
>	ON Trans_employees_queues.cTrans_employees_queues_pk = ;
>	Employee_queue_schedules.cTrans_employees_queues_fk ;
>	WHERE <<m.lcFilter>>
>ENDTEXT
>
>text TO lcSQLStrTemp NOSHOW TEXTMERGE PRETEXT 7
>	SELECT Trans.cTrans_pk, Usgrlink.cUsGrlink_pk, ;
>		Users.cUserID, Trans.yCurrent_balance_amount ;
>	FROM TRANS INNER JOIN Trans_employees_queues ;
>	ON Trans.cTrans_pk = Trans_employees_queues.cTrans_fk ;
>	INNER JOIN UsGrLink ON ;
>	Trans_employees_queues.cUsGrLink_fk = UsGrLink.cUsGrLink_pk ;
>	INNER JOIN USERS ON Users.iID = Usgrlink.iUserID ;
>	INNER JOIN Employee_queue_schedules ;
>	ON Trans_employees_queues.cTrans_employees_queues_pk = ;
>	Employee_queue_schedules.cTrans_employees_queues_fk ;
>	WHERE <<m.lcFilter>> AND ;
>	(Trans_employees_queues.iTemporary_Assignment_Flag = 1 AND ;
>   	 Trans_employees_queues.tStart_Date <= <<m.lcDateTime>> ;
>	 AND Trans_employees_queues.tExpire_Date >= <<m.lcDateTime>>)
>ENDTEXT
>
>if empty(m.lcGroupBy)
>	llReturn = RunSQL(m.lcSQLStr, m.tcAlias)
>	
>else
>	if RunSQL(m.lcSQLStr, 'cQueueInfoTemp')
>		text TO lcSQLStr TEXTMERGE noshow
>	 	  SELECT <<m.lcFieldList>> from cQueueInfoTemp ;
>	 	  <<m.lcGroupBy>>
>		ENDTEXT
>
>
>Now, I want to combine results of the two selects into the final one. However, I don't want to include accounts twice, in other words, if I have cTrans_pk in the first select (lcSQLStr) and the same accounts in my second (lcSQLStrTemp), I don't want to include them in my final result. I'm sorry, if the explanation is not clear enough, but may be you still can understand me and help me to correctly combine the results.
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform