This is a stretch for the piriformis muscle. The piriformis muscle lies deep within each buttock.
Some people experience leg pain (sciatica) which is caused by the piriformis being too tight. To be sure, there are other causes of leg pain (bulging discs, stenosis of the spine, pinching of a spinal nerve etc). This is meant as general health knowledge, talk to your medical provider to understand your personal pain pattern.
To do this stretch, sit forward in the chair and cross right leg over the left leg, interlace your fingers and grasp the right knee and draw it toward the left shoulder. Sit up tall and if more stretch is desired rotate to the right.
Hold the stretch for 30-60 seconds. As the muscle relaxes, take up the slack, drawing the right knee closer toward the left shoulder. Repeat to the other side. The picture below demonstrates the stretch to the right piriformis.