Note that if you use aliases in your snippet (e.g., orders AS o), you’ll need to use those aliases outside of the snippet to refer to that data in your query. Of course, if you make a mistake and cause chaos, you can simply correct the code, save the snippet again, and restore order to the universe. Updating the SQL code of a snippet will update every query that uses that snippet, so make sure to test your code before saving it to avoid breaking people’s questions. Previewing and inserting a snippet from the Snippets sidebar.Ĭlicking on a snippet’s name in the snippet sidebar will insert it at your cursor’s current location in the query. Standardization: how does your organization define a popular product? Is it by number of units sold? Or by reviews with an average rating greater than 4? You can define those qualifications for a popular product and codify them in a SQL snippet,, or by selecting them from the snippet sidebar: Fig. ![]() ![]() There are three main use cases for SQL snippets: Now let’s dig in to why they’re so useful. That’s all it takes to create and use a snippet. by database or by type of snippet, and let you grant or deny access to specific folders or subfolders. These folders and their permissions help you keep your snippets organized, e.g. We’ll also cover a feature exclusive to some paid plans in Metabase: Snippet Folders. Snippets are a simple but powerful feature, so let’s unpack them. ![]() Highlight SQL code and save it as a snippet. Anyone with SQL editor permissions for at least one database can use, create, and edit snippets. If you ever need to update that code, you can edit the snippet, and those changes will propagate to all questions that use that snippet. SQL Snippets allow you to save SQL code as a snippet, and then you or other SQL authors can refer to that snippet in different SQL queries.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |