>
> Adding the customer id to your returning clause and using update..from
> could help:
>
> with data as (
> delete from orders
> where customer_id =
> returning customer_id, price
> ), total as (
> select customer_id, sum(price) as total_price
> from data
> On 6 Oct 2020, at 7:37, Hemil Ruparel wrote:
>
> I am trying to delete orders for a given customer on a given date and add the
> cost of those orders to credit for the customer.
>
> So far, I came up with this:
> ```
> with data as (
> delete from orders
> where customer_id =
On Tue, Oct 06 2020, Hemil Ruparel wrote:
> with data as (
> delete from orders
> where customer_id =
> and date = '2020-10-05' returning price
> ), total as (
> select sum(price) from data
> )
> update paymentdetail
> set temp_credit = temp_credit + (select * from total)
> w
I am trying to delete orders for a given customer on a given date and add
the cost of those orders to credit for the customer.
So far, I came up with this:
```
with data as (
delete from orders
where customer_id =
and date = '2020-10-05' returning price
), total as (
select su