Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
INNER JOIN with TOP syntax
Message
From
03/06/2013 14:34:46
 
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01575526
Message ID:
01575529
Views:
25
>
>SELECT T1.*, T2.*
>FROM myTable T1
>
>CROSS APPLY (SELECT TOP (1) * from myTable2 T2 where T2.FK = T1.PK ORDER BY T2.SomeColumn DESC) T2
>
>Take a look at
>Including an Aggregated Column's Related Values Erik and mine blog presenting several solutions of the problem with explanations for each
>
>Including an Aggregated Column's Related Values - Part 2 my blog post with use cases for the previous blog

This works, thanks.

I tried various combinations but I saved the CROSS APPLY syntax for the end. It seems in this case that is the only way of doing it. Or, could there be a way of doing it with INNER JOIN as well, but would probably be not as fast I guess.
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform