increment rows based on a record in postgresql

1

I have a query that returns the quantity and initial value and I want to turn this query into multiple rows by quantity.

Example:

Inquiry:

select 3 as numero, 10001 as valorinicial

Expected output:

 id | valor
 ----------

  1. 10001
  2. 10002
  3. 10003

Any suggestions with postgresql or postgresql / php ?

    
asked by anonymous 20.07.2018 / 17:40

1 answer

2

With the native function generate_series (start, stop, step)

For your case

Select generate_series(10001 , 10003,1);

See not working on SQLFiddle

    
20.07.2018 / 17:52