This RookUnderpromotion.cql finds Rookending studies wherein a pawn promotes to Knight, Bishop or Rook.

Created by Peter Boll.

(match
 :pgn heijden.pgn
 :output RookUnderpromotion.pgn
(position
:flipcolor
:variations
:promote [NnBbRr]
:piececount [QqNnBb] 0
:piececount R 1 8
:piececount r 1 8)
)

250 studies are found. Here a few presented: