apache / apache/shardingsphere

SQLSERVER Page query field return error

Open
#23,968 0 comments 0 reactions 0 assignees View on GitHub
db: SQLServer
Dominant language
Java
Stars
20.8k
Forks
6.9k
Avg merge
11h 38m
Merged PRs (30d)
326

Description

The sql server paging sql I use is as follows:
_select * from ( select TOP 30 ROW_NUMBER() OVER(ORDER BY P.BIZDATE DESC ) AS rownum, P.* FROM (select * from (
select
tao.dealType,
tao.orderNo,
tao.SourceNo,...
from TradeApi_Order tao
) f ) P ) as temp where temp.rownum > 0 ORDER BY temp.rownum_

The result field of the sql query is:
top(index:1), dealType(index:2) ,orderNo(index:3), SourceNo(index4)

However, the dealType index of shardingsphere record is as follows:
![0091d288fed8e44475145569486d09a](https://user-images.githubusercontent.com/28945646/216561616-ba316004-a791-4cf7-875f-51940169b91b.png)
He seems to have skipped the index of the top field。

This causes all obtained field indexes to be reduced by 1.

version: 5.1.2

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported SQL Server paging query against ShardingSphere 5.1.2 and inspect how the result fields are indexed. Compare the returned positions for TOP, dealType, orderNo, and SourceNo; the issue is done when the field indexes match the SQL result order.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, sql
Domain
databases
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.