Grouping and Aggregating Records

Options
Is there a way to create this query using Xano?  I don't see a way to use "HAVING"

SELECT user_id, COUNT(*)
FROM comments
WHERE photo_id <= 50
GROUP BY user_id
HAVING COUNT(*) > 20;

Comments

  • Ray Deck
    Ray Deck Trusted Xano Expert ✭✭✭
    Options
    AFAIK you are correct - there is support for aggregation (under "output") but not for aggregate filtering ("having"). 

    The solution I use is to prune the result set in the function stack and then return the pruned list. Since aggregation has already seriously cut down on the resultset count, the performance is not seriously impaired compared to just doing it in the SQL for most use cases.