Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Is it possible
Message
 
 
À
12/02/2013 14:10:41
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Titre:
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Desktop
Divers
Thread ID:
01565799
Message ID:
01565801
Vues:
70
You can use expression in top clause
SELECT TOP (expression) ...
>Before I make myself completely insane trying to do it, say I have a TestFrameWork table that looks like
>
>Cat     TypeB      TypeC     TypeD     TypeE
>----------------------------------------------------------------
>40          5              3             6            4
>41
>.
>.
>.
>
>
>Where the numbers 5,3, etc are the number of records I need of each Cat and Type and will change periodically but I can't predict what they will be; the 'B','C','D','E' are the difficulty letters (DiffLet). But I need to be able to pull x number of records based on Cat and DiffLet
>
>I know we can say
>
>Select top 5 from (filename) where Cat = '40' and DiffLet = 'B'
>Union
>(Select top 3 from (filename) where Cat = '40' and DiffLet = 'C'
>Union
>...
>
>
>
>but is it possible to say
>
>Select top TestFrameWork.TypeB from (filename) where Cat = '40' and DiffLet = 'B'
>
>?
--sb--
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform