Convert query from Mysql to curl

SELECT

	st.branch_id branch_id,

	st.branch_name branch_name,

	st.dept_id dept_id,

	st.dept_name dept_name,

	ROUND(SUM(IFNULL(st.work_allotment,0.0)/10000000)) work_allotment,

	ROUND(SUM(IFNULL(st.progMonth_Exp,0.0)/10000000)) progMonth_Exp,

	ROUND(SUM(IFNULL(st.month_Exp,0.0)/10000000)) month_Exp,

	ROUND(SUM(IFNULL(st.yearlyMonth_Exp,0.0)/10000000)) yearlyMonth_Exp,

	COUNT(DISTINCT st.division_office_id,st.work_id) total_works


FROM	
	mis_monthly_work_statistics st
  
       group by dept_id
;

I need to convert this query to curl.
I am able to perform aggregation as follows:

{
  "aggs": {
    "By Dept": {
      "terms": {
        "field": "dept_id",
        "size": 10
      },
      "aggs": {
        "work_allotment": {
          "sum": {
            "field": "work_allotment"
          }
        },
        "progmonth_exp":{
          "sum": {
            "field": "progmonth_exp"
          }
        },
        "month_exp":{
          "sum": {
            "field": "month_exp"
          }
        },
        "yearlymonth_exp":{
          "sum": {
            "field": "yearlymonth_exp"
          }
        }
      }
    }
  }
}

But I alaso need to get the fields that are required.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.