Home Forums SQL Server 2008 SQL Server 2008 - General Error With Query RE: Error With Query
imex
Ten Centuries
Points: 1234
More actions
October 6, 2012 at 11:37 pm
#1546469
Try:
with CTE as
(
select *, ROW_NUMBER() OVER(PARTITION BY AraziID
ORDER BY EghdamatSabt DESC) AS RowNum
from AraziEghdamat
)
select a.*, e.*
from Arazi as a
join CTE as e on e.AraziID = a.AraziID and e.RowNum = 1
Hope this helps.