This commit is contained in:
2025-11-16 09:10:10 +01:00
parent 1bbbd16e03
commit 4f38a8793a
4 changed files with 104 additions and 16 deletions

25
banque.functions.md Normal file
View File

@@ -0,0 +1,25 @@
# Fonctions
```sql
insert into exchange_rate values
('EUR', '1999-01-04', 1),
('USD', '1999-01-04', 1.1789),
('YEN', '1999-01-04', 133.73);
```
```sql
create or replace function latest_exchange_rate (
p_code text,
p_date date
)
returns decimal
language sql
as $$
select rate
from exchange_rate
where currency_code = p_code
and date < p_date
order by date desc
limit 1;
$$;
```