Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to generate JSON sample

ronald_2017Oct 15 2021 — edited Oct 15 2021

Hi All,

I have table and I want to generate the following JSON sample. However, I used group by, so which functions should I use? All columns in the JSON output exist in the table.

Oralce 19C

{
    "cheque_type":"55",
    "amount":1000,
    "people":[
        {"id":"XXX",
        "age":"30",
        "name":"AAA"},
        {"id":"YYY",
        "age":"35",
        "name":"BBB"},
        {"id":"YYY",
        "age":"38",
        "name":"BBB"}
            ],
            "bank_list":[
                {"bank_name":"A Bank",
                "country":"USA"},
                {"bank_name":"B Bank",
                "country":"UK"},
                {"bank_name":"C Bank",
                "country":"France"}
                ],
                "cheque":
                {"cheque_no": "CCC",
                "cheque_bank": "CCC",
                "cekBankasi_branch": "CCC",
                "cekBankasi_date": "",
                },
            "createuser":"TTTT"
} 
SELECT 
    JSON FUNCTIONS
FROM T_TABLE 
GROUP BY cheque_no, cheque_bank, cekBankasi_branch, cekBankasi_date, cheque_type, amount;

Thanks in advance

This post has been answered by Solomon Yakobson on Oct 15 2021
Jump to Answer

Comments

Post Details

Added on Oct 15 2021
3 comments
144 views