Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Joining when using SELECT DISTINCT

Author  Topic 

Mondeo
Constraint Violating Yak Guru

287 Posts

Posted - 2008-07-10 : 06:33:25
I've got this

SELECT DISTINCT vehicleref,manufacturer,model,derivative,matrixfrontpageposition,studioimages FROM vwAllMatrixVehicles

Also have a second table like this

VehicleRef Position
1234 2
1235 4
1236 3
1237 1

I want to use my first select statement but ORDER BY the position in the second table - is that possible.

Thanks

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-07-10 : 06:43:41
[code]SELECT DISTINCT v.vehicleref,v.manufacturer,v.model,v.derivative,v.matrixfrontpageposition,v.studioimages
FROM vwAllMatrixVehicles v
JOIN (SELECT VehicleRef ,Position FROM SecondTable)t
ON t.VehicleRef =v.vehicleref
ORDER BY t.Position[/code]
Go to Top of Page
   

- Advertisement -