Skip to main content
100%

GROQ - tricks

✓ Published0🌍 Public
Aabonello
Last edited Apr 13, 2026
Created on Apr 13, 2026

This example demonstrates a collection of GROQ query patterns for retrieving and aggregating data from a Sanity CMS dataset. The code shows how to filter and sort project milestones to find the latest status, use boolean checks to determine project completion, implement pagination for posts, and perform SQL-like grouping by counting related documents. It introduces GROQ's native aggregation functions such as `count()`, `math::sum`, `math::avg`, and `math::max` to compute statistics directly within the query language. The group-by example uses a parent-centric projection with the `references(^._id)` function to achieve relational grouping.

AI-generated description

Similar vizzes