Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
select json_extract(other_detail,'$.is_substitute_allowed') as substitute,
count(date(order_date)) as order_date
from prescription_metrics
group by 1;
I am unable to group by over the extracted value from other_detail(which can be 0 or 1 only) in AWS Athena. 'other_detail' is a JSON while order_date is of type date. Error:
GROUP BY clause cannot contain aggregations or window functions.
The query works fine when not using GROUP BY
–
–
select substitute, order_date from
(select json_extract(other_detail,'$.is_substitute_allowed') as substitute,
count(date(order_date)) as order_date
from prescription_metrics)
group by 1;
BTW, did you mean to have count(distinct(order_date))
or any other date manipulation (day
?) on the order_date column?
–
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.