Skip to content
Advertisement

Is there better way to subtract of sum fields without summing again in postgresql

Let’s say Point table looks like this,

And I write sql like below

It works well. But I’m not sure it’s a best way to get subtraction of summed fields. I think it calculate unnecessary summing again.

Is there any better idea?

Thanks!

Advertisement

Answer

What about that:

or:

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement