Skip to content
Advertisement

Why SUM values are wrong in postgresql query?

I use postgresql and I have trouble in forming the correct query to get the desired result.

I have a query

And it gives me result as below.

I wish to get the result like

So I tried to SUM the third column and so changed the query a bit like this,

But the result is like below,

Fist this is not what I expected and the third column in above result has some values with + sign in it and also a float value!!!

I don’t really understand what is wrong here. Please help me to understand this and give me idea how I can get the desired result as I stared above.

Thanks in Advance!

Advertisement

Answer

Since you want to get the information based on ticket and submitter then you need to group only by those columns. So something like

Also I don’t see the ticket_custom used anywhere in results so probably can drop that entirely also

Or just join them without the subselect.

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