Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««34567

ROW_NUMBER(): An Efficient Alternative to Subqueries Expand / Collapse
Author
Message
Posted Friday, June 18, 2010 3:26 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 11:46 AM
Points: 116, Visits: 98
-- how about?
SELECT
pv.ProductID
, pv.Version
, pv.MinorVersion
, pv.ReleaseVersion
, pv.StandardCost
FROM Production.ProductVersion pv WITH (NOLOCK)
WHERE EXISTS (
SELECT *
FROM (
SELECT TOP 1
pv2.ProductID
, pv2.Version
, pv2.MinorVersion
, pv2.ReleaseVersion
FROM Production.ProductVersion pv2 WITH (NOLOCK)
WHERE pv2.ProductID = pv.ProductID
ORDER BY
pv2.ProductID DESC
, pv2.Version DESC
, pv2.MinorVersion DESC
, pv2.ReleaseVersion DESC
) pv2
WHERE pv2.ProductID = pv.ProductID
AND pv2.Version = pv.Version
AND pv2.MinorVersion = pv.MinorVersion
AND pv2.ReleaseVersion = pv.ReleaseVersion
)

Post #939875
« Prev Topic | Next Topic »

Add to briefcase «««34567

Permissions Expand / Collapse