Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Removing records from a SQL query
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2008
Application:
Web
Divers
Thread ID:
01445297
Message ID:
01446424
Vues:
25
This might sound silly and not 'best practiced' but if the original query performs good enough could you just wrap it as sub-query and then filter the result?
Select * From
(previous query) a
Where filterfield = 1

Silly me....


>>>If you want the fastest result, then try packed value solution from that blog.
>>
>>Thanks
>
>Here it is - no need for derived tables
>
>-- Test query
>declare @t table(PK int, ChildPK int, Field int)
>insert into @t values(1,1,1), (1,2,3), (1,3,0), (2,4,5), (2,1,1), (2,2,3)
>
>select PK, MAX(Field) as MaxField, 
>cast(SUBSTRING(max(cast(Field as binary(10)) + CAST(ChildPK as binary(10))),11,10) as int) as ChildPk 
>from @t group by PK
>
Ricardo A. Parodi
eSolar, Inc.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform