Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to exclude duplicates from Select with UNION?
Message
De
28/03/2006 23:43:14
Neil Mc Donald
Cencom Systems P/L
The Sun, Australie
 
 
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
OS:
Windows XP SP2
Database:
Visual FoxPro
Divers
Thread ID:
01108675
Message ID:
01108681
Vues:
15
Hi,
Would the DISTINCT clause be what your looking for ?

>Hi everybody,
>
>Here is my code to get queues by role
>
>
>local lcSQLStr, lcFilter1, lcFilter2
>
>lcFilter1 = [Employee_Queue_Profiles.cUsGrLink_fk = '] + crsUsGrLink.cUsGrLink_pk + [']
>lcFilter2 = [Queue_Names.cDepartment_Code = '] + ;
>	strtran(left(cDepartments.cDepartment_Code,1),'C','O') + [']
>
>text TO lcSQLStr TEXTMERGE noshow
>   SELECT 1 as iSelected, ;
>   Employee_Queue_Profiles.iDefault_queue_flag as iDefault_Queue_Flag, ;
>   Queue_Names.cQueue_names_pk, Queue_Names.cQueue_name, ;
>   Queue_Names.cDepartment_code, Queue_Names.cQueue_type_code, Queue_Names.cQueue_type_id ;
>   FROM Employee_Queue_profiles INNER JOIN Queue_Names ;
>   ON Employee_Queue_Profiles.cQueue_Names_fk = Queue_Names.cQueue_Names_pk ;
>   WHERE Employee_Queue_Profiles.iActive_Flag = 1 AND <<m.lcFilter1>> ;
>   UNION ;
>   select 0 as iSelected, 0 as iDefault_Queue_flag, ;
>    Queue_Names.cQueue_names_pk, Queue_Names.cQueue_name, ;
>   Queue_Names.cDepartment_code, Queue_Names.cQueue_type_code, Queue_Names.cQueue_type_id ;
>   FROM Queue_Names WHERE Queue_Names.cQueue_Name NOT LIKE 'UNASSIGNED%' AND <<m.lcFilter2>> ;
>   ORDER BY 4
>ENDTEXT
>
>if RunSQL(m.lcSQLStr, 'curTempQueues')
>	zap in cQueueNames
>	insert into cQueueNames select * from curTempQueues
>	GO TOP IN cQueueNames
>	use in curTempQueues
>endif
>
>If I have queues in Employee_Queue_Profile, I don't want them listed twice. However, currently they are listed twice, I believe, because of extra fields. Is my only option to do this in two separate select statements?
>
>Thanks a lot in advance.
Regards N Mc Donald
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform