Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • Interestingly, the records that should be listed (have a relationship based on batch_code) are retrieved as text; is that correct? Unfortunately, the data that has been retrieved does not accurately provide the expected data mentioned in my question thread. Commented Apr 15 at 3:16
  • You missed the "key_name" and "value" keys and its values. The "prod_name" shouldn't be null, except for "key_name" and "value". Still, your answer was great; you just need to refine it. Commented Apr 15 at 3:34
  • One more thing, which I noticed in your query, for batch_code "BGUID-2025-04-11-6D81B58FAE94" and "BGUID-2025-04-10-20239FD2059F", you need to prevent "amount_to_pay" from summing up with other entries sharing the same "batch_code", as it represents the total of the corresponding list's "disc_price" (programmatically). Additionally, the "quantity" key and its value are missing. Commented Apr 15 at 5:39
  • 1
    I had a feeling that I'd miss something important. The issue that I wanted to present was how to get the json to group the orders that are joined by batch, and list them individually when they are not in a batch. Commented Apr 15 at 16:15
  • Could you please edit your answer to show how you would correct it to provide the expected output? I'd like to compare your approach to mine. Kindly disregard the backslash characters included in the output for now. Commented Apr 16 at 1:38