---
title: "result"
description: "The result keyword in SQL is not commonly used across all database systems, but in DuckDB, it has a specific meaning within the context of recursive queries."
canonical: "https://motherduck.com/glossary/result/"
related:
  - title: "Results | MotherDuck Docs"
    url: "https://motherduck.com/docs/concepts/results/"
  - title: "RESULT | MotherDuck Docs"
    url: "https://motherduck.com/docs/sql-reference/motherduck-sql-reference/result/"
  - title: "Analyze JSON Data Using SQL and DuckDB"
    url: "https://motherduck.com/blog/analyze-json-data-using-sql/"
gated_asset:
  title: "Dives: Interactive Dashboards & Embedded Analytics"
  url: "https://motherduck.com/product/dives/"
---

# result

> The result keyword in SQL is not commonly used across all database systems, but in DuckDB, it has a specific meaning within the context of recursive queries.

The `result` keyword in SQL is not commonly used across all database systems, but in DuckDB, it has a specific meaning within the context of recursive queries. When writing a recursive Common Table Expression (CTE), `result` is used to reference the output of the previous iteration of the recursive part. This allows you to build upon the results of each recursive step.

Here's an example using DuckDB to generate a sequence of numbers:

```sql
WITH RECURSIVE countdown(n) AS (
    SELECT 5 AS n  -- Base case
    UNION ALL
    SELECT n - 1   -- Recursive case
    FROM result    -- 'result' refers to the previous iteration
    WHERE n > 0
)
SELECT * FROM countdown;
```

This query will produce:

```
 n
---
 5
 4
 3
 2
 1
```

The `result` keyword helps create powerful recursive queries for tasks like traversing hierarchical data structures or generating sequences. It's important to note that not all database systems use `result` in this way, so this usage is specific to DuckDB's implementation of recursive CTEs.
