Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Question on best way to code a query...
Message
De
16/10/2003 09:12:39
 
 
À
Tous
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Question on best way to code a query...
Divers
Thread ID:
00839218
Message ID:
00839218
Vues:
58
OK, here's the question...

I have two tables, one a master and the other a detail.

The master looks like this...

ID Name
1 Kevin
2 Steve

The history table [ a very large history file] looks like this..

ID Status
1 A
1 C
1 D
1 F
1 G
2 B
2 C

I want to create a flat file that will look like this, where I need a flag to indicate whether the user has had even one instance of a status...

ID Name A_Flag B_Flag C_Flag D_Flag etc.
1 Kevin .T. .F. .F. .T.
2 Steve .F. .T. .F. .F.

I wrote a query to do this, but it involves several subqueries and outer joins and some CASE instances to look for each status. It works, but I'm curious how others would approach this. Performance of the query is important.

Thanks!
Kevin
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform