Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Querying distinct values in Ballerina Query Expressions

Is it possible to query DISTINCT values using Ballerina Query Expressions?

string[]|error connectorProducts = from record {string product;} {product} in products
        select product;

connectorProducts should only have DISTINCT values at the end.

Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

This can be achieved by incorporating a group by clause.

from record {string product;} {product} in products
      group by product
      select product;

Also see

Note that there’s an open spec issue to look into the possibility of adding an array:unique function as a straightforward alternative for when we just want to filter out unique members from an array.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading