# \#sql-tutorial

**URL:** https://meta.discourse.org/tag/sql-tutorial/630.md

[Latest](https://meta.discourse.org/latest.md) · [Categories](https://meta.discourse.org/categories.md) · [Tags](https://meta.discourse.org/tags.md)

---

## [Using Parameters in Data Explorer Queries](https://meta.discourse.org/t/using-parameters-in-data-explorer-queries/277934)

<div class="topic-metadata">

**Author:** [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Replies:** 6\
**Last updated:** [February 10, 2026, 2:20pm UTC](https://meta.discourse.org/t/using-parameters-in-data-explorer-queries/277934 "2026-02-10T14:20:25Z")

</div>

Parameters are a powerful tool that can be used in Data Explorer queries on Discourse. Parameters allow for more dynamic and customizable queries, and instead of hard-coding values in your queries, you can declare vari…

---

## [Tips for Exporting User Data](https://meta.discourse.org/t/tips-for-exporting-user-data/313711)

<div class="topic-metadata">

**Author:** [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Replies:** 0\
**Last updated:** [June 26, 2024, 12:04am UTC](https://meta.discourse.org/t/tips-for-exporting-user-data/313711 "2024-06-26T00:04:06Z")

</div>

When users need customized or detailed data exports that go beyond the basic User Data Export available from their preference page, administrators can perform user data exports using the Data Explorer plugin. This proc…

---

## [Using FILTER to summarise data](https://meta.discourse.org/t/using-filter-to-summarise-data/289298)

<div class="topic-metadata">

**Author:** [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Replies:** 0\
**Last updated:** [December 20, 2023, 8:31am UTC](https://meta.discourse.org/t/using-filter-to-summarise-data/289298 "2023-12-20T08:31:29Z")

</div>

Overview In this report, we’ll explore a SQL query that uses the FILTER function to segment user data based on their activity summary preferences. The FILTER function is a powerful tool in SQL that allows for conditional…

---

## [Handling Null Values with COALESCE](https://meta.discourse.org/t/handling-null-values-with-coalesce/278813)

<div class="topic-metadata">

**Author:** [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Replies:** 0\
**Last updated:** [September 13, 2023, 1:15am UTC](https://meta.discourse.org/t/handling-null-values-with-coalesce/278813 "2023-09-13T01:15:35Z")

</div>

In this tutorial, we will explore the use of the COALESCE function in Data Explorer SQL queries. COALESCE allows you to handle NULL values in your query results. If you have NULL values in your data, you can use COALE…

---

## [Using STRING\_AGG for Concise Query Results](https://meta.discourse.org/t/using-string-agg-for-concise-query-results/278628)

<div class="topic-metadata">

**Author:** [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Replies:** 0\
**Last updated:** [September 11, 2023, 11:43pm UTC](https://meta.discourse.org/t/using-string-agg-for-concise-query-results/278628 "2023-09-11T23:43:14Z")

</div>

The string\_agg function in SQL is an aggregate function that concatenates (joins) strings from multiple rows into a single string with various options. It’s particularly useful when you want to combine values from a col…

---

## [Using DATE\_TRUNC for Data Aggregation](https://meta.discourse.org/t/using-date-trunc-for-data-aggregation/278095)

<div class="topic-metadata">

**Author:** [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Replies:** 0\
**Last updated:** [September 6, 2023, 11:24pm UTC](https://meta.discourse.org/t/using-date-trunc-for-data-aggregation/278095 "2023-09-06T23:24:38Z")

</div>

The date\_trunc function is a powerful tool in SQL. It allows you to truncate a TIMESTAMP or an INTERVAL value based on a specified date part, which makes it an invaluable function when you want to aggregate or group da…

---

## [Formatting Data Explorer Table Results](https://meta.discourse.org/t/formatting-data-explorer-table-results/277939)

<div class="topic-metadata">

**Author:** [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Replies:** 0\
**Last updated:** [September 5, 2023, 11:37pm UTC](https://meta.discourse.org/t/formatting-data-explorer-table-results/277939 "2023-09-05T23:37:33Z")

</div>

In Discourse, you have the ability to enhance the appearance of your Data Explorer query results. Formatting table results in the Data Explorer can be done by using special syntax in your SQL queries, which allows you…

---

## [Data Explorer Tutorial - Part 2 - Discourse SQL Basics](https://meta.discourse.org/t/data-explorer-tutorial-part-2-discourse-sql-basics/277927)

<div class="topic-metadata">

**Author:** [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Replies:** 0\
**Last updated:** [September 5, 2023, 10:11pm UTC](https://meta.discourse.org/t/data-explorer-tutorial-part-2-discourse-sql-basics/277927 "2023-09-05T22:11:48Z")

</div>

:discourse: This guide is a continuation of the Data Explorer Tutorial - Part 1 - Writing Your First Query. Now that you’ve seen how the Data Explorer works in action, let’s talk about some SQL basics that will be h…

---

## [Data Explorer Tutorial - Part 1 - Writing Your First Query](https://meta.discourse.org/t/data-explorer-tutorial-part-1-writing-your-first-query/277925)

<div class="topic-metadata">

**Author:** [@SaraDev](https://meta.discourse.org/u/SaraDev)\
**Replies:** 0\
**Last updated:** [September 5, 2023, 10:03pm UTC](https://meta.discourse.org/t/data-explorer-tutorial-part-1-writing-your-first-query/277925 "2023-09-05T22:03:38Z")

</div>

:discourse: Want to extract some data from your Discourse site but not sure where to start? You’ve come to the right place! This is a tutorial guide for beginners who are new to the Data Explorer. If you’re already f…

---

## [Categories and their Subcategories using OR](https://meta.discourse.org/t/categories-and-their-subcategories-using-or/276583)

<div class="topic-metadata">

**Author:** [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Replies:** 0\
**Last updated:** [August 25, 2023, 8:37am UTC](https://meta.discourse.org/t/categories-and-their-subcategories-using-or/276583 "2023-08-25T08:37:03Z")

</div>

Sometimes you want to find information about topics that are in certain categories, plus all the topics in those categories’ subcategories too. You can add the category\_id of each subcategory to your query, but this can …

---

## [Adding a date parameter](https://meta.discourse.org/t/adding-a-date-parameter/276158)

<div class="topic-metadata">

**Author:** [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Replies:** 2\
**Last updated:** [August 22, 2023, 1:10pm UTC](https://meta.discourse.org/t/adding-a-date-parameter/276158 "2023-08-22T13:10:09Z")

</div>

Often you will want to pull out data for a specific time period. You can do this by hard-coding in your time period into the query itself, but to make your report more future-proof you can add a date parameter: This qu…

---

## [Common Discourse data tips](https://meta.discourse.org/t/common-discourse-data-tips/276148)

<div class="topic-metadata">

**Author:** [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Replies:** 3\
**Last updated:** [August 22, 2023, 11:39am UTC](https://meta.discourse.org/t/common-discourse-data-tips/276148 "2023-08-22T11:39:00Z")

</div>

This is a good example of a couple of Discourse data quirks that can help you get more accurate results when building your queries. As most posts and topics are ‘soft-deleted’ when you delete them this means they will s…

---

## [Using VALUES or CASE to make your results more readable](https://meta.discourse.org/t/using-values-or-case-to-make-your-results-more-readable/276153)

<div class="topic-metadata">

**Author:** [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Replies:** 0\
**Last updated:** [August 22, 2023, 8:48am UTC](https://meta.discourse.org/t/using-values-or-case-to-make-your-results-more-readable/276153 "2023-08-22T08:48:14Z")

</div>

Sometimes when building a query with the data explorer you’ll find codes are used in the results rather than their textual equivalents. The field often has a key in the data explorer tree, but these don’t tend to be as u…
