Update DBMS/SQL/Week6/writeup.md
This commit is contained in:
parent
f80463ae74
commit
90db880472
@ -28,12 +28,13 @@ TOTAL_ACCD(2024)
|
|||||||
```SQL
|
```SQL
|
||||||
create or replace procedure tot_damage
|
create or replace procedure tot_damage
|
||||||
(driver in varchar2, year in number) is
|
(driver in varchar2, year in number) is
|
||||||
damage number := 0; -- initialize damage to 0
|
damage number := 0;
|
||||||
begin
|
begin
|
||||||
select sum(damage_amount) into damage
|
select sum(damage_amount) into damage
|
||||||
from participated pa
|
from participated pa
|
||||||
natural join accident ac
|
natural join accident ac
|
||||||
where pa."driver_id#" = driver -- use the correct column name with quotes
|
where pa."driver_id#" = driver
|
||||||
|
with quotes
|
||||||
and extract(year from ac.accd_date) = year;
|
and extract(year from ac.accd_date) = year;
|
||||||
|
|
||||||
dbms_output.put_line('total damage: ' || nvl(damage, 0));
|
dbms_output.put_line('total damage: ' || nvl(damage, 0));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user