SQL SELECT to get the first N positive integers

前端 未结 10 1387

I need to get a result set containing the first N positive integers. Is it possible to use only standard SQL SELECT statement to get them (without any count table provided)?

10条回答
  •  臣服心动
    2020-11-30 13:16

    This may help

    To obtain a random integer R in the range i <= R < j, use the expression FLOOR(i + RAND() * (j – i)). For example, to obtain a random integer in the range the range 7 <= R < 12, you could use the following statement:

    SELECT FLOOR(7 + (RAND() * 5));

提交回复
热议问题