Snippets let you share small, reusable bits of SQL with your team.
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"
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>
command
/ ctrl
+ k
→ "Create snippet"command
/ ctrl
+ ;
(semicolon)command
/ ctrl
+ k
→ "View snippet"Suggest a snippet here.