tsql - Get max value within an inline view having a TOP clause -
i trying max value within inline view , returning me maximum value within inline view if inline view had no top clause.
the table dbo.details in query below contains 650 records. need max value top 200 records, query below gets me max value on records in details table batchnumber = 341.
is there subtle point missing? goal max value within top(200) records. using sql server 2008 r2.
select max(a.detailsrecordid) (select top(200) npd.detailsrecordid, npd.batchnumber dbo.details npd npd.batchnumber = 341)
top 200 based on nothing. there no order by.
even table clustered pk there no guaranteed order without order by.
Comments
Post a Comment