Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Metabase Up and Running

You're reading from   Metabase Up and Running Introduce business intelligence and analytics to your company and make better business decisions

Arrow left icon
Product type Paperback
Published in Sep 2020
Publisher Packt
ISBN-13 9781800202313
Length 332 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Tim Abraham Tim Abraham
Author Profile Icon Tim Abraham
Tim Abraham
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Section 1: Installing and Deploying Metabase
2. Chapter 1: Overview of Metabase FREE CHAPTER 3. Chapter 2: Deploying Metabase with AWS 4. Section 2: Setting Up Your Instance and Asking Questions of Your Data
5. Chapter 3: Setting Up Metabase 6. Chapter 4: Connecting to Databases 7. Chapter 5: Building Your Data Model 8. Chapter 6: Creating Questions 9. Chapter 7: Creating Visualizations 10. Chapter 8: Creating Dashboards, Pulses, and Collections 11. Chapter 9: Using the SQL Console 12. Section 3: Advanced Functionality and Paid Features
13. Chapter 10: Advanced Features, Getting Help, and Contributing 14. Other Books You May Enjoy

Creating saved SQL snippets

It may feel like a lot of the SQL we've written has been copied, pasted, and reused over and over again from other queries. This is common in SQL, common in programming in general, and considered an anti-pattern. In fact, there's a principle in computing called the DRY principle, which stands for Don't Repeat Yourself (https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). The principle is about how you should not rewrite the same line or lines of code again and again, as it is time-consuming and introduces more risk of bugs from typos.

Metabase has taken this principle to heart and has a feature called Saved SQL Snippets. A SQL snippet is a block of SQL that you can call upon in a single variable whenever you want to reuse it.

Throughout this chapter and book, we've been working with some iteration of the same query that takes the Orders table and flattens it out, such that every row becomes an item ordered, rather than an entire...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime