Group by, having sql ..How to Convert

hello.

I want to achieve some functionality which is available in SQL data stores. I have tried a lot but having a hard time achieving that functionality with elasticsearch.

SQL
SELECT CD_HASH, COUNT(*)
FROM GRW_MAIL_RECEIVER_LIST
GROUP BY CD_HASH
HAVING MAX(TM_RCV) <> MIN(TM_RCV)

/
{

"size": 0,

"aggs":{

    "group_by_state":{

        "terms": {

            "field": "cd_hash.keyword"

        }

    }

}

}
/

Please help me.. :thinking:

Hi,

Which version and license of ElasticSearch are you using? If you are not using the OpenSource version (the free basic license would be enough), there is a REST API to translate SQLs into ElasticSearch queries: SQL translate API | Elasticsearch Guide [7.13] | Elastic

Best regards
Wolfram

1 Like

I could not solve.
But the information you provided was helpful.
Thank you :slight_smile:

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