-- Create table
CREATE TABLE benford (num INTEGER);

-- Seed table
INSERT INTO benford (num) VALUES (1);
INSERT INTO benford (num) VALUES (1);
INSERT INTO benford (num) VALUES (2);

-- Populate table
INSERT INTO benford (num)
  SELECT
    ult + penult
  FROM
    (SELECT MAX(num) AS ult FROM benford),
    (SELECT MAX(num) AS penult FROM benford WHERE num NOT IN (SELECT MAX(num) FROM benford))

-- Repeat as many times as desired
--    in Oracle SQL*Plus, press  a lot of times
--    or wrap this in a loop, but that will require something db-specific...

-- Do sums
SELECT
  digit,
  COUNT(digit) / numbers AS actual,
  log(10, 1 + 1 / digit) AS expected
FROM
  (
    SELECT
      FLOOR(num/POWER(10,LENGTH(num)-1)) AS digit
    FROM
      benford
  ),
  (
    SELECT
      COUNT(*) AS numbers
    FROM
      benford
  )
GROUP BY digit, numbers
ORDER BY digit;

-- Tidy up
DROP TABLE benford;