Count of nested group by

I am trying to get the count of nested group by in the main group by set. Code snippet is available below, and mcount to be filled with count of nested data. Your quick help would be appreciated.

GroupByAccum<STRING user_account_id, SumAccum<INT> trans_count, SumAccum<FLOAT> total_amt, GroupByAccum<STRING id, SumAccum<INT> trans_count> users , SumAccum<INT> **mcount** > @@bgroup; 

StartU = {User.*};
users = SELECT dt from StartU : src - (Receive:e) - Transaction: dt
Accum @@bgroup += (dt.to_account -> 1, dt.total_amoun, (dt.from_account -> 1),  **0**);

Print(@@bgroup)

Thank You!

1 Like

Current Output:
{ "user_account_id": "0000010", "trans_count": 10, "total_amt": 100, "users": [{ "id": "0020", "trans_count": "5" }, { "id": "0030", "trans_count": "5" }], "mcount": **0** }

Expected Output :
{ "user_account_id": "0000010", "trans_count": 10, "total_amt": 100, "users": [{ "id": "0020", "trans_count": "5" }, { "id": "0030", "trans_count": "5" }], "mcount": **2** }

example

interpret QUERY () SYNTAX v1 {
GroupByAccum<string a, SumAccum< int > b, GroupByAccum<string c, SumAccum<int> d> e> @@test;

@@test += ("a"-> 1, ("c"-> 2));
@@test += ("a"-> 2, ("b"-> 2));
@@test += ("c"-> 3, ("b"-> 1));

foreach (key1, val1, val2) in @@test do
     print key1, val1, val2, val2.size();
end;
}

output:

{
  "error": false,
  "message": "",
  "version": {
    "schema": 0,
    "edition": "enterprise",
    "api": "v2"
  },
  "results": [
    {
      "key1": "c",
      "val2": [{
        "c": "b",
        "d": 1
      }],
      "val1": 3,
      "val2.size()": 1
    },
    {
      "key1": "a",
      "val2": [
        {
          "c": "c",
          "d": 2
        },
        {
          "c": "b",
          "d": 2
        }
      ],
      "val1": 3,
      "val2.size()": 2
    }
  ]
}

Will that not be an query performance issue while requesting for huge amount of data.

This will work fine.

I use similar structures a lot and they are generally quite performant.