ROWNUM equivalent in Centura SQLBase (aka Gupta)
One way to emulate row numbers in DBMS that do not have window function is using a triangular self join. It's usually not very efficient though.

Given that the primary key is (employee_no, date, group_code):

SELECT
    a.employee_no, a.date, a.group_code,
    COUNT(*) AS group_running_number
FROM
    tableX AS a
  JOIN
    tableX AS b
      ON  a.group_code = b.group_code
      AND ( a.date &gt; b.date
         OR a.date = b.date AND a.employee_no &gt;= b.employee_no
          )
GROUP BY
    a.group_code, a.date, a.employee_no ;


The order used for the assigning of row numbers above is: (date ASC, employee_no ASC)

An index on (group_code, date, employee_no) will improve efficiency I think.