create cursor x1 ( i1 i ) for i = 1 to 9 insert into x1 values ( i ) endfor select x1.i1 as p1, x2.i1 as p2, x3.i1 as p3, x4.i1 as p4, x5.i1 as p5, x6.i1 as p6, x7.i1 as p7, x8.i1 as p8, x9.i1 as p9 ; from x1 ; left join x1 as x2 on x1.i1 != x2.i1 ; left join x1 as x3 on x1.i1 != x3.i1 and x2.i1 != x3.i1 ; left join x1 as x4 on x1.i1 != x4.i1 and x2.i1 != x4.i1 and x3.i1 != x4.i1 ; left join x1 as x5 on x1.i1 != x5.i1 and x2.i1 != x5.i1 and x3.i1 != x5.i1 and x4.i1 != x5.i1 ; left join x1 as x6 on x1.i1 != x6.i1 and x2.i1 != x6.i1 and x3.i1 != x6.i1 and x4.i1 != x6.i1 and x5.i1 != x6.i1 ; left join x1 as x7 on x1.i1 != x7.i1 and x2.i1 != x7.i1 and x3.i1 != x7.i1 and x4.i1 != x7.i1 and x5.i1 != x7.i1 and x6.i1 != x7.i1 ; left join x1 as x8 on x1.i1 != x8.i1 and x2.i1 != x8.i1 and x3.i1 != x8.i1 and x4.i1 != x8.i1 and x5.i1 != x8.i1 and x6.i1 != x8.i1 and x7.i1 != x8.i1 ; left join x1 as x9 on x1.i1 != x9.i1 and x2.i1 != x9.i1 and x3.i1 != x9.i1 and x4.i1 != x9.i1 and x5.i1 != x9.i1 and x6.i1 != x9.i1 and x7.i1 != x9.i1 and x8.i1 != x9.i1 ; into cursor ThePermutations readwrite *Each of the uniform numbers of the first four batters totals 21. *Batting between players 1 and 2, are players whose uniforms total 18. *Between players 2 and 3, the uniforms total 24. *Between 3 and 4, the total is 14, and *Between 4 and 5, the total is 9. delete for p1 + p2 + p3 + p4 != 21 && apply first constraint * 31680 left scan scatter to thisLineup i = ascan( thisLineup, 1 ) j = ascan( thisLineUp, 2 ) i1 = min( i, j ) i2 = max( i, j ) lnTotal = 0 for i = i1 + 1 to i2 - 1 lnTotal = lnTotal + thisLineup[i] endfor if ( lnTotal != 18 ) delete endif endscan * 640 left scan scatter to thisLineup i = ascan( thisLineup, 2 ) j = ascan( thisLineUp, 3 ) i1 = min( i, j ) i2 = max( i, j ) lnTotal = 0 for i = i1 + 1 to i2 - 1 lnTotal = lnTotal + thisLineup[i] endfor if ( lnTotal != 24 ) delete endif endscan * 4 left scan scatter to thisLineup i = ascan( thisLineup, 3 ) j = ascan( thisLineUp, 4 ) i1 = min( i, j ) i2 = max( i, j ) lnTotal = 0 for i = i1 + 1 to i2 - 1 lnTotal = lnTotal + thisLineup[i] endfor if ( lnTotal != 14 ) delete endif endscan * 1 left>To anyone interested in this puzzle