CertSafari
    Databricks Certified Data Analyst Associate· Lessons

    Domain 6 · Lesson 29/39

    Databricks SQL alert conditions: value, operator, threshold and schedule

    Configure an alert with a desired threshold and destination.

    12 min read
    2.29% of exam
    6 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Explain what a Databricks SQL alert evaluates and the three states an evaluation can end in
    • Choose between the first value of a column and an aggregation across all rows for an alert condition
    • Set the operator and threshold, test the condition, and handle queries that return no rows
    • Schedule an alert and avoid skipped runs caused by the workspace active-run limit

    Key concept

    Databricks SQL alert — A saved object that runs its own SQL query on a schedule, reduces the result to one value, and compares that value with a threshold. Users or notification destinations are notified when the comparison is met.

    1.What an alert evaluates

    An alert turns a query into a monitor. It runs on a schedule, checks a condition against the result, and notifies people when the condition holds. Teams use alerts for business KPIs, data quality, cost trends and warehouse health. The common thread is that nobody needs to keep a dashboard open to notice when a number moves.

    Every evaluation ends in one of three states. TRIGGERED means the latest run met the condition, OK means it did not, and ERROR means the evaluation itself failed. Current alerts have no UNKNOWN state; that state belonged only to legacy alerts, which still sit on their own tab of the Alerts page.

    The alert owns its query. You write the SQL in the alert editor itself, because an existing saved query cannot be reused when creating an alert. Two more constraints shape that SQL. First, alerts do not support queries with parameters, so a query that depends on a query or dashboard parameter has to have its values written into the SQL. Second, the alert runs on a SQL warehouse that you pick in the Compute selector, and the editor shows whether that warehouse is running. See what a SQL warehouse does.

    The parts of the alert editor
    Editor areaWhat you set there
    Query editorThe SQL the alert runs and evaluates
    ComputeThe SQL warehouse that runs the alert query
    ScheduleHow often the alert runs
    SharePermissions for others in the workspace
    ConditionThe value, operator and threshold that trigger a notification
    NotificationsUsers or notification destinations to alert, plus an optional repeat frequency
    AdvancedNotify on OK, empty result state, and the notification template

    Checkpoint 1 of 8· Match them up

    You are setting up an alert in the alert editor. Match each editor area to what you configure there.

    Tap a term, then the definition that fits it.

    Sources12

    2.Choosing the value the condition checks

    A query usually returns many rows, but the condition compares one number with a threshold, so the alert has to reduce the result to a single value. The Condition section gives two ways to do it, and choosing the wrong one gives the wrong answer.

    First value of a column reads the chosen column in the top row and ignores every other row. Use it when the query already puts the answer in that row. One case is a query that computes the total itself. Another is a result sorted newest-first, where only the latest hour or day matters. If a query sorts hourly error_count values in descending time order, the first value is the latest hour's count. Summing or averaging the column would mix in all the older hours.

    An aggregation across all rows applies a function such as SUM or AVERAGE to one column over the whole result. Use it when the number you care about is spread across rows. If a revenue query returns one row per store, the first value is just one store's revenue. Choosing Sum on revenue gives the daily total across all stores, which is the number to compare with a $50,000 floor. Average divides the total by the number of stores, so it gives a per-store figure and never the total.

    The aggregation runs inside the alert, not in your query. The alert wraps your SQL in a common table expression and runs an aggregating query over it. For a query SELECT 1 AS column_name with a SUM aggregation, each run executes WITH q AS (SELECT 1 AS column_name) SELECT SUM(column_name) FROM q. The value that gets evaluated is always decided here: by the query's own SQL plus the Condition settings. The notification template only formats the message after the value has been evaluated. A LIMIT or HAVING written into a template changes nothing about which rows are checked.

    Checkpoint 2 of 8· Check yourself

    A query returns one row per sales region with an order_count column. The team wants a notification when the combined order count across all regions falls below 2,000. Which Condition setting should the alert use?

    Checkpoint 3 of 8· Check yourself

    An alert uses a SUM aggregation on amount. To make the alert compare only the most recent 24 rows against the threshold, an analyst adds LIMIT 24 to the custom notification template. What effect does this have on the value the alert evaluates?

    Checkpoint 4 of 8· Exam question

    A BI team wants a Databricks SQL alert to fire whenever the total daily revenue reported by a query drops below $50,000, and the underlying query returns one row per store with a revenue column across many stores. Which condition configuration correctly triggers the alert based on the overall daily total rather than any single store's value?

    Checkpoint 5 of 8· Exam question

    An alert's underlying query returns a result set sorted so that the most recent hourly error_count value appears in the first row, followed by older hourly values in subsequent rows. The analyst wants the alert to evaluate only that most recent hour's count, ignoring the rest of the rows. Which condition setting achieves this?

    Sources23

    3.Operator, threshold and testing the condition

    With the value chosen, you pick a column, a logical operator such as >, and a threshold. The threshold defaults to Static value, a fixed number that you type in. In the webhook payload, a threshold is described as either a value or a query result column. This means one column of the result can serve as the comparison point for another, for example when a query returns both a measurement and the limit it should stay under.

    Test condition runs the query and shows whether the alert would trigger on the current data. Use it before saving. You can change the threshold and test again until the alert fires where you expect it to.

    A condition looks at one column, so put any logic that spans several columns into the query. In that case the query returns a flag, and the alert triggers when the flag equals 1:

    A query that combines two counts into one Boolean-style value for the alert to checksql
    SELECT CASE WHEN drafts_count > 10000 AND archived_count > 5000 THEN 1 ELSE 0 END
    FROM (
    SELECT sum(CASE WHEN is_archived THEN 1 ELSE 0 END) AS archived_count,
    sum(CASE WHEN is_draft THEN 1 ELSE 0 END) AS drafts_count
    FROM queries) data

    An alert's status reflects only its most recent run. Take an alert that checks whether cats is above 1500. It stays TRIGGERED for as long as the value stays above 1500, and once the value falls to 1470 it shows OK. That OK does not mean the alert never fired. It only means the latest evaluation did not meet the condition.

    Checkpoint 6 of 8· Fill the gap

    The alert should fire only when the drafts count is above 10,000 and the archived count is also above 5,000 at the same time. Which keyword completes the query so that it returns 1 only in that case?

    SELECT CASE WHEN drafts_count > 10000  ?  archived_count > 5000 THEN 1 ELSE 0 END
    FROM (
    SELECT sum(CASE WHEN is_archived THEN 1 ELSE 0 END) AS archived_count,
    sum(CASE WHEN is_draft THEN 1 ELSE 0 END) AS drafts_count
    FROM queries) data

    Checkpoint 7 of 8· Check yourself

    Every hour, an alert checks whether error_rate is above 5. On Friday the Alerts page shows its status as OK, and a manager concludes that the error rate never went above 5 that week. How accurate is that conclusion?

    Sources243

    4.Empty results and the alert schedule

    Sometimes a query returns no rows, and then there is no value to compare. Advanced settings handles this with Empty result state, which sets the status the alert should return when that happens. Set it on purpose. A query such as "orders with a failed payment in the last hour" returns nothing on a good day, and you choose which status that good day reports.

    The schedule controls how often all of this runs. Click the calendar icon to open Edit schedule and choose an interval from the drop-down menus, for example every 5 minutes from 0 minutes past the hour. To write the schedule in Quartz cron syntax, select Show cron syntax. Use Run now on the alert page to evaluate the alert immediately, outside its schedule.

    By default, a workspace allows 250 alert runs to be active at the same time. When a scheduled alert fires while every run slot is busy, that run is skipped and nothing is evaluated. Look for this in the evaluation history: gaps at a shared schedule time, while a manual Run now of the same alert succeeds. The fix is to stagger the schedules, so alerts run at 01:30, 01:32 and 01:34 rather than all at 01:30. If the workspace still hits the limit regularly, Databricks Support can raise the quota.

    Checkpoint 8 of 8· Check yourself

    On a normal day, an alert's query "orders with a failed payment in the last hour" returns no rows at all. The team wants to choose the status the alert reports on those days. Which setting controls it?

    Sources2

    Sources

    (6)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Evaluations resolve to OK, TRIGGERED, or ERROR.”
      ↩︎ What an alert evaluates
      “An existing saved SQL query cannot be reused when creating an alert.”
      ↩︎ What an alert evaluates
    2. 2.
      “Alerts do not support queries with parameters.”
      ↩︎ What an alert evaluates
      “Choose the SQL warehouse that runs the alert query.”
      ↩︎ What an alert evaluates
      “You can set an alert condition on the first value of a column in the query result”
      ↩︎ Choosing the value the condition checks
      “Set the threshold value to Static value 4000. Static value is selected by default.”
      ↩︎ Operator, threshold and testing the condition
      “Click Test condition to preview the alert and test whether the alert would trigger with the current data.”
      ↩︎ Operator, threshold and testing the condition
      “Empty result state: Set a special status to return when the query returns no results.”
      ↩︎ Empty results and the alert schedule
      “Optionally, select the Show cron syntax checkbox to edit the schedule in Quartz Cron Syntax.”
      ↩︎ Empty results and the alert schedule
      “Each workspace has a default limit of 250 simultaneous active alert runs.”
      ↩︎ Empty results and the alert schedule
      “set an aggregation across all rows of a single column, such as SUM or AVERAGE”
      ↩︎ Exam trap 1
      “Notifications: Indicate which users or notification destinations should be alerted when the threshold value falls outside of the expected range.”
      ↩︎ Checkpoint
      “select to set an aggregation across all rows of a single column, such as SUM or AVERAGE”
      ↩︎ Checkpoint
      “When all run slots are in use and a scheduled alert fires, the alert run is skipped and the alert does not evaluate.”
      ↩︎ Prediction
    3. 3.
      “The alert wraps the original query text in a common table expression (CTE) and performs a wrapping aggregation query on it”
      ↩︎ Choosing the value the condition checks
      “your query can implement the alert logic and return a Boolean value for the alert to trigger on”
      ↩︎ Operator, threshold and testing the condition
      “The alert wraps the original query text in a common table expression (CTE) and performs a wrapping aggregation query on it”
      ↩︎ Exam trap 2
    4. 4.
      “The value or query result column that the source is compared against.”
      ↩︎ Operator, threshold and testing the condition

    Also cited

    Continue to part 2 of 2

    Alert notification destinations and templates in Databricks SQL

    Spotted a mistake, or was something unclear? Tell us.