Fix the bug of MSSQL paging

This commit is contained in:
wenzi1 2020-03-20 00:33:20 +08:00
parent 6174097a07
commit f667cbc2a2

View File

@ -153,17 +153,15 @@ func (d *DriverMssql) parseSql(sql string) string {
"SELECT * FROM "+
"(SELECT ROW_NUMBER() OVER (ORDER BY %s) as ROWNUMBER_, %s ) as TMP_ "+
"WHERE TMP_.ROWNUMBER_ > %d AND TMP_.ROWNUMBER_ <= %d",
orderStr, selectStr, first, limit,
orderStr, selectStr, first, first+limit,
)
} else {
if first == 0 {
first = limit
} else {
first = limit - first
}
sql = fmt.Sprintf(
"SELECT * FROM (SELECT TOP %d * FROM (SELECT TOP %d %s) as TMP1_ ) as TMP2_ ",
first, limit, selectStr,
limit, first+limit, selectStr,
)
}
default: