Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
SQL Statement How To
Message
 
 
À
17/06/2009 17:05:49
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2005
Application:
Desktop
Divers
Thread ID:
01404764
Message ID:
01406758
Vues:
29
>I used the following.
>
>DECLARE @StdLevel TABLE (StidenId int, Level int)
>
>INSERT INTO @StdLevel
>SELECT StudentId, MAX(Level)
>FROM (SELECT StudentId, 1 AS Level
> FROM Level1
> UNION ALL
> SELECT StudentId, 2 AS Level
> FROM Level2
> UNION ALL
> SELECT StudentId, 3 AS Level
> FROM Level3
> UNION ALL
> SELECT StudentId, 4 AS Level
> FROM Level4
> UNION ALL
> SELECT StudentId, 5 AS Level
> FROM Level5) Levels
>GROUP BY StudentId
>
>SELECT .....
>FROM ...
>INNER JOIN @StdLevel S
>
>
>Thanks Again

You could have used CTE instead of the table variable - not sure which one is more effective.
If it's not broken, fix it until it is.


My Blog
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform