@Amrutha Thank you for reaching out.
The error message "Cannot have aggregate and non-aggregate selectors in query" in Azure Cosmos Cassandra DB typically occurs when you are trying to execute a query that contains both aggregate and non-aggregate selectors.
In Cassandra, you cannot mix aggregate functions (such as COUNT, SUM, AVG, MIN, MAX) with non-aggregate functions (such as SELECT, WHERE, ORDER BY) in the same query. This is because aggregate functions operate on groups of rows, while non-aggregate functions operate on individual rows.
Aggregate functions are supported in Azure Cosmos DB for SQL API and MongoDB API, but they are not supported for Cassandra API and Table API.
In SQL API, you can use aggregate functions such as COUNT, SUM, AVG, MIN, and MAX in your queries. Here is an example:
SELECT COUNT(1) FROM c WHERE c.status = 'completed'
In MongoDB API, you can use aggregate functions such as $count, $sum, $avg, $min, and $max in your queries. Here is an example:
db.orders.aggregate([
{ $match: { status: "completed" } },
{ $group: { _id: null, count: { $sum: 1 } } }
])
Hope that helped you.
Regards,
Oury