Introduction

Snippets let you share small, reusable bits of SQL with your team.

Demo

https://youtu.be/KwUyIdkBPt0

Creating your first Snippet

To create a snippet hit command / ctrl + k → "Create snippet"

Working with dates is a great example, check out this snippet we use at SeekWell which creates three date formats from a timestamp

date_trunc('day', {{column_name}})::date as "{{alias}}_day",
date_trunc('week', {{column_name}})::date as "{{alias}}_week",
date_trunc('month', {{column_name}})::date as "{{alias}}_month"

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/4dbdc496-73cb-496a-9963-b39de3e5135e/Untitled.png

Once you type {{ you'll see the variable added to "Defaults". Here you can add a commonly used value for the variable (e.g. created_on).

<aside> 💡 Variables are optional, not adding variables will create a "static snippet"

</aside>

Navigation

https://s3-us-west-2.amazonaws.com/secure.notion-static.com/d05157d1-f532-4deb-acb9-247f01254755/Untitled.png

Library

SnippetLibrary

Suggest a snippet here.

Other resources to jump start