Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
UNION
Message
De
17/01/2001 11:59:17
Greg Coopman
Gc Systems Corporation
Hollywood, Floride, États-Unis
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
UNION
Divers
Thread ID:
00464747
Message ID:
00464747
Vues:
57
I have a SELECT command that I need to pull out user according to their contact status. The hierarchy is: PRIMARY, SECONDARY, SUBSTITUTE. In other words, if a RequestID + RouteOrder has three contacts each with a different status as listed previously, thenn only the one with PRIMARY will be selected. I am trying to use a UNION, but don't think my output to be distinctive enough while still getting the UserID back. Heres the code. Do you have a suggestions.

SELECT a.[RequestID] + a.[RouteOrder],
a.[ID],
a.[UserIDContact],
a.[IsRequired],
, c.[TypeIDContactStatus],
FROM ContactStatus_vw c,
AvailablePendingRoutePointUser_vw a
WHERE a.[TypeIDContactStatus] = c.[TypeIDContactStatus]
AND c.[Code] = 'PRIMARY'
UNION
SELECT a2.[ID],
a2.[RequestID],
a2.[UserIDContact],
a2.[IsRequired],
a2.[RouteOrder],
c2.[TypeIDContactStatus]
FROM ContactStatus_vw c2,
AvailablePendingRoutePointUser_vw a2
WHERE a2.[TypeIDContactStatus] = c2.[TypeIDContactStatus]
AND c2.[Code] = 'SECONDARY'
UNION
SELECT a3.[ID],
a3.[RequestID],
a3.[UserIDContact],
a3.[IsRequired],
a3.[RouteOrder],
c3.[TypeIDContactStatus]
FROM ContactStatus_vw c3,
AvailablePendingRoutePointUser_vw a3
WHERE a3.[TypeIDContactStatus] = c3.[TypeIDContactStatus]
AND c3.[Code] = 'SUBSTITUTE'
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform