Hi,

I have below SQL statement and I would like to use some variables in order to prevent repeating select statements. I do not know how to do that, but I remember seeing something similar. So, hoping that is possible.

```
update saydetay
set
sayilan = coalesce((select sum(miktar) from sayokutmalar where id = 'D95D796C-1BB1-4420-9CB7-99CEA30CE1A6' and islemturu = 'G' and iptal = 0 and sayokutmalar.urunkodu = saydetay.urunkodu), 0)
,
satilan = coalesce((select sum(miktar) from sayokutmalar where id = 'D95D796C-1BB1-4420-9CB7-99CEA30CE1A6' and islemturu = 'C' and iptal = 0 and sayokutmalar.urunkodu = saydetay.urunkodu), 0)
,
sayimmiktar = coalesce((select sum(miktar) from sayokutmalar where id = 'D95D796C-1BB1-4420-9CB7-99CEA30CE1A6' and islemturu = 'G' and iptal = 0 and sayokutmalar.urunkodu = saydetay.urunkodu), 0) - coalesce((select sum(miktar) from sayokutmalar where id = 'D95D796C-1BB1-4420-9CB7-99CEA30CE1A6' and islemturu = 'C' and iptal = 0 and sayokutmalar.urunkodu = saydetay.urunkodu), 0)
,
fark = coalesce((select sum(miktar) from sayokutmalar where id = 'D95D796C-1BB1-4420-9CB7-99CEA30CE1A6' and islemturu = 'G' and iptal = 0 and sayokutmalar.urunkodu = saydetay.urunkodu), 0) - coalesce((select sum(miktar) from sayokutmalar where id = 'D95D796C-1BB1-4420-9CB7-99CEA30CE1A6' and islemturu = 'C' and iptal = 0 and sayokutmalar.urunkodu = saydetay.urunkodu), 0) - miktar
```

Thanks.