Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Question on best way to code a query...
Message
From
16/10/2003 10:45:03
 
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Miscellaneous
Thread ID:
00839218
Message ID:
00839263
Views:
20
see my reply in your other post :)

>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
Insanity: Doing the same thing over and over and expecting different results.
Previous
Reply
Map
View

Click here to load this message in the networking platform