You can translate the question and the replies:

facing error : 'The SELECT list of a grouped query contains at least one invalid expression. If a SELECT list has a GROUP BY, the list may only contain valid grouping expressions and valid aggregate expressions.'

Hi team, I have tried by executing the below query and it works. SELECT FLOOR("TC_1"."inventory_days" / (NULLIF(5,0.0)* 1.0)) "COL_1", COUNT("TC_1"."inventory_days") "COL_2" FROM "storesales" "TC_1" group by 1 But if i am adding the group by column to the below it throws an error 'The SELECT list of a grouped query contains at least one invalid expression. If a SELECT list has a GROUP BY, the list may only contain valid grouping expressions and valid aggregate expressions.' Query executed : SELECT FLOOR("TC_1"."inventory_days" / (NULLIF(5,0.0)* 1.0)) "COL_1", COUNT("TC_1"."inventory_days") "COL_2" FROM "storesales" "TC_1" INNER JOIN ( SELECT 'No' as "COL_1", 1 as "NULL_COL" ) "MDF_1" ON ("TC_1"."issouthindia" = "MDF_1"."COL_1") group by 1. Why group by works in the first query and not working in the second query?
user
12-10-2023 02:10:13 -0400
code

1 Answer

Hi, I would include all the non aggregate fields in the SELECT statement into GROUP BY section to make the query work as every non aggregate column used in the SELECT statement must be added to GROUP BY clause. For more information you can take look at the below documentations: * [Group BY Clause](https://community.denodo.com/docs/html/browse/latest/en/vdp/vql/queries_select_statement/group_by_clause/group_by_clause) * [JOIN Operation](https://community.denodo.com/docs/html/browse/latest/en/vdp/vql/queries_select_statement/from_clause/join_operation) Hope this helps!!
Denodo Team
12-10-2023 08:08:01 -0400
code
You must sign in to add an answer. If you do not have an account, you can register here