Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Removing records from a SQL query
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01445297
Message ID:
01446424
Views:
26
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.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform