Find Jobs
Hire Freelancers

PostgreSQL: create aggregate method iterating over json

$10-30 USD

Cancelled
Posted over 7 years ago

$10-30 USD

Paid on delivery
Using the data below ``` create table my_table (my_column json); insert into my_table values ('{"total": 10, "custom": 1}'::json), ('{"total": 9, "custom": 2}'::json), ('{"total": 21, "custom": 7}'::json), ('{"total": 11, "custom": 9}'::json), ('{"total": 12, "custom": 10}'::json); ``` Objective: Create 3 methods to aggregate the data in the manner below. ``` select max_json_key('total', my_column) from my_table; # results in {"total": 21, "custom": 7} select min_json_key('total', my_column) from my_table: # results in {"total": 9, "custom": 2} select avg_json_key('total', my_column) from my_table: # results in {"total": 12, "custom": 10} ``` - The resulting value returns the full json object for the corresponding value. - keys are not aggregated, only the "totals" key is used to determine which entry fits the criteria. Thank you!
Project ID: 11010071

About the project

Remote project
Active 8 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs

About the client

Flag of UNITED STATES
Lakewood Ranch, United States
5.0
3
Payment method verified
Member since Dec 26, 2015

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.