I have written a simple query against a table in a Postgres database that contains a column "manifest" of type json
. Each cell contains a very long value and I am extracting the numerical value for "size".
I need to create a new column (perhaps call it "size in MB"), and perform division against size. Specifically, I need to take the value of size and divide it by 1024, two times. I have tried every example I can find to no avail.
Here is my current query, and a small snippet of the result:
select customers.name, images.customer_id, images.captured_at, images.name,
manifest -> 'size' as image_size
from public.images
inner join public.customers on customers.id = images.customer_id
where (captured_at > current_date - interval '12 months')
order BY captured_at desc
Name customer_id captured_at name image_size
Acme Inc 12345 2022-05-31 Central HMA 628032520
The goal is to take image_size
, divide by 1024 two times, and store the result in a new column called "size in MB". So in this case, the result of the math would be 598.