Generating a postgres query with no rows
For testing purposes, it is nice to be able to simulate a query that does not result in any rows.
``` sql
select * from generate_series(0, -1) x;
x
---
(0 rows)
```
This is because (from the docs):
> When step is positive, zero rows are returned if start is greater than stop.
Step (the third argument to generate series) defaults to 1, so anything where the _from_ has to go backwards to get to the _to_ will result in 0 rows.
``` sql
select * from generate_series(4, 3) x;
x
---
(0 rows)
```
And now you can see how `sum()` behaves without any rows:
``` sql
select sum(x) from generate_series(1, 0) x;
sum
-----
ΓΈ
(1 row)
```
Ohhh, it returns null. I hope you're planning for that.
chriserin
April 25, 2019