在select查询中隐藏列?

vq8itlhq  于 2021-08-13  发布在  Java
关注(0)|答案(2)|浏览(388)

嗨,我试图隐藏在我的结果中显示的totalrank列,因为我只需要在这个查询中使用它来帮助排序项目。我不需要显示这些信息。

SELECT TOP 15 G.CharacterName, G.JobCode, G.PvPExp, D.PVPWin, D.PVPLose, D.PVPGiveUp, RANK() OVER (ORDER BY TotalRank ASC ) as TotalRank
FROM PvPRanking as G
INNER JOIN PVPScores as D
ON G.CharacterID = D.CharacterID
tzxcd3kk

tzxcd3kk1#

您可以使用以下命令

SELECT TOP 15 G.CharacterName, G.JobCode, G.PvPExp, D.PVPWin, D.PVPLose, D.PVPGiveUp
FROM PvPRanking as G
INNER JOIN PVPScores as D
ON G.CharacterID = D.CharacterID
ORDER BY  RANK() OVER (ORDER BY TotalRank ASC )
t30tvxxf

t30tvxxf2#

您可以创建结果表的别名,并从中选择除total rank列之外的所有内容。

SELECT t1.CharacterName, t1.JobCode, t1.PvPExp, t1.PVPWin, t1.PVPLose, t1.PVPGiveUp
FROM 
(SELECT TOP 15 G.CharacterName, G.JobCode, G.PvPExp, D.PVPWin, D.PVPLose, D.PVPGiveUp, 
RANK() OVER (ORDER BY TotalRank ASC ) as TotalRank
FROM PvPRanking as G
INNER JOIN PVPScores as D
ON G.CharacterID = D.CharacterID) AS t1

相关问题