When we’re working with fields that have websites in them, one of the things that we should be doing with them is to double-check that they’re well-formed and usable. Thankfully, Snowflake has a function just for that. With the PARSE_URL function, we can check out if everything is properly formed – meaning that we have…… Continue reading Check Out these URLs with Snowflake Functions
Category: Snowflake
In CASE You Want to Use Logic in Snowflake
Sometimes you need to check one field to see if you want to display another field. Sometimes you show one of two fields depending on the value in yet another field. Sometimes you just need to relax… https://www.youtube.com/watch?v=SxS_DvDiuRI Today, though, we’re going to go thru a myriad of functions that you can use in Snowflake…… Continue reading In CASE You Want to Use Logic in Snowflake
Figuring out the Number of Months Between Days
Figuring out the number of years or months between 2 dates shouldn’t be hard. For some reason though, for a lot of database systems it is. Take, for example, SQL Server. If I want to know the number of months between 1/1/2023 and 7/4/2023, it’s not too hard. A simple DATEDIFF function and we’re golden.…… Continue reading Figuring out the Number of Months Between Days
Getting the Minimum or Maximum of One Column
By the title of this post, you’re thinking “Ho hum. Sherpa will tell us about the stupid MIN and MAX functions in Snowflake and how great they are.” Well, they are great. Let’s not kid ourselves about that one. SELECT department_id, MIN(employee_id) AS FirstEmp FROM public.employees GROUP BY department_id ORDER BY department_id; This simply tells…… Continue reading Getting the Minimum or Maximum of One Column
Next Friday Will Be Here Before You Know it
Sometimes, you’ll be asked to show the next Friday after a given date in a report. Sometimes, it’s the next Monday. Let’s work thru how to do it in both SQL Server and Snowflake for comparison… One of the two ways we’ll go over in SQL Server is using the DateFirst operator. This operator actually…… Continue reading Next Friday Will Be Here Before You Know it
This is the end… of the month.
In SQL Server, we’re used to finding the end of the month via a few different methods. We can always use the DateAdd and DateDiff functions to get our data – which sometimes takes a bit of work – or we can use the EOMonth function. Notice that the DateAdd and DateDiff functions return a…… Continue reading This is the end… of the month.
Distinctity. Yes, it’s a thing.
There are a lot of things that can be said about the keyword DISTINCT within Snowflake. One of them you’re probably used to, and one of them you probably aren’t. SELECT DISTINCT DEPARTMENT_ID FROM public.employees; In this case, DISTINCT is simply ensuring we have unique data. If you remove the DISTINCT keyword, the version I’m…… Continue reading Distinctity. Yes, it’s a thing.
More Fun Dealing with Strings
When you’re working with a database, it’s very hard to not deal with strings at some point in your journey. There are lots of different functions that you will be working with when you’re working with strings. Today, I want to go over some of the basic ones that you’ll use in Snowflake. The first…… Continue reading More Fun Dealing with Strings
Creating Random Data in Snowflake
One of the many things that the business team asks me to do is to create random-ish data. Thankfully, in Snowflake, there are many ways to make this happen. Today, I want to go thru just a few of them. Perhaps the one that most people are familiar with is making Snowflake create a random…… Continue reading Creating Random Data in Snowflake
Cleaning Up Your Data the Easy Way in Snowflake
I don’t know about y’all but I have to work with dirty data. A lot. When you’re working with dirty data, one of the many things you can run into is that when you try to divide two numbers – you can cause a huge error because you tried to perform a mathematical no-no -…… Continue reading Cleaning Up Your Data the Easy Way in Snowflake