SQL Server SQL add empty rows

o8x7eapl  于 2023-11-16  发布在  其他
关注(0)|答案(1)|浏览(152)

I need to add empty rows to a SQL SELECT statement in such a way that the result is in multiples of 10, meaning if there are 8 rows in a Tables 2 empty Rows should be added so that the select statement has 10 rows and if there are say 16 rows in a Table 4 empty rows should be added so that the select statement has 20 rows etc, etc.

In short at all times the rows selected must be 10,20,30,40, etc, etc.

5t7ly7z5

5t7ly7z51#

In PostgreSQL something like this should do the job:

select mycol from mytable 
  union all
select null from generate_series(1,round((select count(*)+4 from mytable),-1))

相关问题