Hi All,I hope this question makes sense.I have a fairly massive query (below), but the gist of it, it has to calculate groups numbers and player order for a field.I've ran into a problem, when the field does not evenly divide into 3, the player order gets thrown off.so if I had something like this for group numbers, how can I get the numbers on the right calculated1 12 12 22 33 13 23 34 14 24 3Right now the results I am getting are wrong1 12 22 32 13 2 3 33 14 2 4 34 1 DECLARE @nr_ttime datetime,@interval tinyint,@starters_time floatSET @nr_ttime = '8:00 AM'SET @interval = 10SET @starters_time = 9999SELECT 123 AS nr_course_id, (CEILING((Row_Number() OVER (ORDER BY nr_group_number, score, r1_ttime, r1_start_hole, r1_player_order, course_priority)) % 3.001) ) player_order, DateAdd(minute, (@interval * nr_group_number - @interval + CASE WHEN (nr_group_number) / @starters_time > 1 THEN (FLOOR ((nr_group_number - 1) / @starters_time) * @interval) ELSE 0 END ),@nr_ttime) nr_ttime, 1 nr_start_hole, (SELECT id FROM flights WHERE event_id = 5008 AND flight_number = 1) nr_flight_id, e.* FROM ( SELECT CEILING( MAX(b.group_order) OVER (PARTITION BY b.event_id) --total groups + 1 - b.group_order) nr_group_number, b.*, c.r1_shots FROM( SELECT a.*, g.ttime r1_ttime, g.start_hole r1_start_hole, gp.player_order r1_player_order, f.flight_number, ec.course_priority, CEILING (rank() OVER (ORDER BY a.score, g.ttime, gp.player_order, g.start_hole, ec.course_priority) / 3.0) group_order, rank() OVER (ORDER BY a.score) position FROM( SELECT p.id player_id, p.first_name, p.last_name, p.city, p.state, p.country, sum(ph.shots-h.par) score, h.event_id FROM players p INNER JOIN player_holes ph ON p.id = ph.player_id INNER JOIN holes h ON h.id = ph.hole_id WHERE h.event_id = 5008 AND ph.round < 2 GROUP BY p.id, p.first_name, p.last_name, p.city, p.state, p.country, h.event_id) a INNER JOIN group_players gp ON gp.player_id = a.player_id INNER JOIN groups g ON gp.group_id = g.id AND g.event_id = a.event_id AND g.round = 1 INNER JOIN flights f ON f.id = g.flight_id INNER JOIN event_courses ec ON ec.course_id = g.course_id AND ec.event_id = g.event_id INNER JOIN event_players ep -- Make sure all the players with scores haven't DQ or WD or other status change ON ep.player_id = a.player_id AND ep.event_id = 5008 AND ep.status_id IS NULL ) b INNER JOIN ( SELECT ph.player_id, SUM(ph.shots) r1_shots FROM player_holes ph INNER JOIN holes h ON h.id = ph.hole_id AND ph.round = 1 AND h.event_id = 5008 GROUP BY ph.player_id ) c ON c.player_id = b.player_id WHERE b.position <= (SELECT ISNULL(cut,9999) FROM events WHERE id = 5008) GROUP BY b.player_id, b.first_name, b.last_name, b.city, b.state, b.country, b.score, b.event_id, b.r1_ttime, b.r1_start_hole, b.r1_player_order, b.flight_number, b.course_priority, b.group_order, b.position, c.r1_shots) eGROUP BY nr_group_number, player_id, first_name, last_name, city, state, country, score, event_id, r1_ttime, r1_start_hole, r1_player_order, flight_number, course_priority, group_order, position, r1_shotsORDER BY nr_group_number