Skip to content

Commit 647d432

Browse files
authored
Fibonacci sequence numbers with recursive in PostgreSQL
1 parent 25d2029 commit 647d432

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

README.md

+12
Original file line numberDiff line numberDiff line change
@@ -1177,6 +1177,18 @@ select max(x), count(x)
11771177
from t
11781178
```
11791179

1180+
[Fibonacci sequence](https://en.wikipedia.org/wiki/Fibonacci_sequence) numbers with recursive in PostgreSQL
1181+
```
1182+
with recursive r(a, b) as (
1183+
select 0::int, 1::int
1184+
union all
1185+
select b, a + b
1186+
from r
1187+
where b < 1000
1188+
)
1189+
select a from r;
1190+
```
1191+
11801192
## Модификация пользовательских данных (DML)
11811193

11821194
### Как добавить или обновить записи одним запросом (UPSERT)?

0 commit comments

Comments
 (0)