If you catch yourself copying the same CASE WHEN or date-trick into five queries, it is time to turn it into a Function. EQQ functions are named, reusable SQL snippets that any query designer can drop into a query.

The fQQ_ convention

By convention, EQQ-managed functions are prefixed with fQQ_ (e.g. fQQ_MonthBucket, fQQ_CurrencyRound2). This keeps them discoverable and prevents collisions with database-native functions.

Manage Functions  -  reusable SQL snippets organized by category.
Manage Functions - reusable SQL snippets organized by category.

Create your first function

  1. Open Manage Functions → New.
  2. Name it fQQ_MonthBucket.
  3. Pick a Category (e.g. Date / Time).
  4. Paste the SQL body: DATEFROMPARTS(YEAR(@d), MONTH(@d), 1).
  5. Declare the parameter @d as date.
  6. Save. The function is now available in the query editor.

Call it from a query

SELECT fQQ_MonthBucket(OrderDate) AS Month, SUM(Amount) AS Revenue
FROM Orders
WHERE OrderDate BETWEEN @StartDate AND @EndDate
GROUP BY fQQ_MonthBucket(OrderDate)
ORDER BY Month

Why this scales

  • One place to fix a bug - fix the function, every query is fixed.
  • One place to update business logic - change the definition of “revenue” in one function.
  • Analysts read a query with fQQ_MonthBucket and instantly know what it does.

Want to see it live? Book a 30-minute demo - we connect EQQ to your database and build a query with you. Book a Demo →