main
Johnathan Douglas 2023-07-10 09:27:03 -03:00
parent 889ee979bf
commit cf39df489a
1 changed files with 3 additions and 4 deletions

View File

@ -73,7 +73,7 @@ where id in (1, 2, 3, . . .);
### Grupo 2: ### Grupo 2:
Atualizar um campo ou mais, mas o valor é o `diferente` para um determinado grupo: Atualizar um campo ou mais, mas o valor é o `diferente` para cada registro:
`Update3Job` `Update3Job`
@ -92,19 +92,18 @@ update transactions
set date='2023-04-03', set date='2023-04-03',
value=30 value=30
where id = 3; where id = 3;
...
``` ```
`Update4Job` `Update4Job`
```sql ```sql
update transactions update transactions
set date= case id when 1 then '2023-04-01'::date set date = case id when 1 then '2023-04-01'::date
when 2 then '2023-04-02'::date when 2 then '2023-04-02'::date
when 3 then '2023-04-03'::date when 3 then '2023-04-03'::date
end end
, ,
value=case id when 1 then 10 value = case id when 1 then 10
when 2 then 20 when 2 then 20
when 3 then 30 when 3 then 30
end end