Jonibek
Jonibek

Reputation: 98

Extract int value from json and multiply by specific value to sum in custom column in PostgreSQL

Good day

please, help with this. I have table "tickets" with column printer_catalog: records from 1st row of column printer_catalog

{"Refueling::HP 1005 (65gr)::2 pcs","Cylinder replacement::HP 1005::4 pcs"}

I need 2nd column with total sum which sums the services. for example:

if "Refueling::HP 1005 (65gr)" then multiply 2 pcs by 3:

2 * 3 = 6

if "Cylinder replacement::HP 1005" then multiply 4 pcs by 3:

4 * 3 = 12

and sum this values 12 + 6 = 18, and show 18 in 2nd custom column.

Upvotes: 0

Views: 32

Answers (0)

Related Questions