Postgresql select 5 rows even if there is 3 row of data -


how select 5 row if there 3 row of data , next 2 row should empty row.

you can union result empty rows, should have same types of columns table. example:

with my_table(id, str, a_date) ( values     (1, 'first', '2017-09-01'::date),     (2, 'second', '2017-09-02'),     (3, 'third', '2017-09-03') )  select * my_table  union  select null::int, null::text, null::date generate_series(1, 5) -- generate 5 empty rows  order id nulls last limit 5   id |  str   |   a_date    ----+--------+------------   1 | first  | 2017-09-01   2 | second | 2017-09-02   3 | third  | 2017-09-03     |        |      |        |  (5 rows)     

Comments

Popular posts from this blog

neo4j - finding mutual friends in a cypher statement starting with three or more persons -

php - How to remove letter in front of the word laravel -

minify - Minimizing css files -