When you use the QueryResult stat in combination with the /xp command, the query result value is the previous value. This affects adding / removing experience and adding / removing levels.
- /scoreboard objectives add xpLevels dummy
- /scoreboard objectives setdisplay sidebar xpLevels
- /scoreboard players set @p xpLevels 0
- /stats entity @p set QueryResult @p xpLevels
- /xp 1L
→ The score has your previous xp level count as value
The following is based on a decompiled version of Minecraft 1.9 using MCP 9.24 beta.
The reason for this is that the method net.minecraft.command.CommandXP.execute(MinecraftServer, ICommandSender, String) first sets the query result value and then changes the experience value.