How to show timestamp difference between max and min in data table

hello everyone


i did show max timestamp and min stamp of each orderId. i want to show difference of them.

i did in dev tools with this query.

GET /toss-v2-confirmed-confirm_response/_search
{
 "aggs": {
    "group_orderId": {
      "terms": {
        "field": "orderId.keyword",
        "size": 10
      },
      "aggs": {
        "min_createdAt": {
          "min": {
            "field": "createdAt"
          }
        },
        "max_createdAt": {
          "max": {
            "field": "createdAt"
          }
        },
        "diff": {
          "bucket_script": {
            "buckets_path": {
              "min_createdAt": "min_createdAt",
              "max_createdAt": "max_createdAt"
            },
            "script": "params.max_createdAt - params.min_createdAt"
          }
        }
      }
    }
  } 
}

also, i did in TSVB as well.


but, i want to show the difference in data table as well. is there any way?