SELECT * FROM mytable ORDER BY mycolumn ASC;
我按特定顺序获得结果表.
在sql中有没有办法有效地找出,给定PK,结果表中的哪个位置将包含我的PK记录?
SELECT RowNr FROM ( SELECT ROW_NUMBER() OVER (ORDER BY mycolumn) AS RowNr,mycolumn FROM mytable ) sub WHERE sub.mycolumn = 42
该示例假设您正在寻找主键42