sql - Select Top 10, but 11 Results -


i have following query select top 10. result show 11 rows, when change select top 20, shows 21?

is there wrong query causing this?

select top 10 format([dutydate],"ddd"", ""dd-mmm-yy") [shift date], count(shifts.id) shifts shifts group format([dutydate],"ddd"", ""dd-mmm-yy") order count(shifts.id) desc; 

when ms access processes top, puts ties in last value. in sql server, equivalent top ties. so, if 11th row has same count 10th, included -- , 12th , on, if counts same.

to fix this, need include sort of tie-breaker. in group by, date. here easy method:

order count(shifts.id) desc, min(dutydate) 

Comments

Popular posts from this blog

java - Suppress Jboss version details from HTTP error response -

gridview - Yii2 DataPorivider $totalSum for a column -

Sass watch command compiles .scss files before full sftp upload -