Get startedGet started for free

Worksheets and a Simple Example - Part II

1. Worksheets and a Simple Example - Part II

So in the last video, we ran our first query on the Tasty Bytes food truck data! Now let’s do more digging to see if we can find out more about what this menu is telling us. To do this, let’s run the next line of code: SELECT TOP 10 * FROM tasty_bytes_sample_data.raw_pos.menu; The results pop up at the bottom, and inspecting the data, I’m seeing different kinds of desserts and beverages offered by a particular food truck brand. (Again, all of this Tasty Bytes data is fictitious – we generated this dataset at Snowflake.) It looks like we have data on how much the goods cost for a given food truck to provide, and how much they’re selling them for. And then we have some ingredients and health information in a semi-structured data format at the end. (We’ll talk more about semi-structured data later in the course.) Let’s indulge and do a little more exploring, because it feels like a shame to have done this work to get a cool dataset in front of us without exploring it a bit. One of the first questions I have is: How many food truck brands are we talking about here? We know from our introduction to Tasty Bytes earlier that there are 450 trucks across the world, but that didn’t tell us how many different brands this represents, and given that this column exists, it seems like Tasty Bytes encompasses multiple brands. To learn more, let’s just run some simple code: SELECT TRUCK_BRAND_NAME, COUNT(*) FROM tasty_bytes_sample_data.raw_pos.menu GROUP BY 1 ORDER BY 2 DESC; This isn’t a course on SQL, but as a reminder, when we GROUP BY 1, it means GROUP BY the first column listed in the select statement – so in this case, TRUCK_BRAND_NAME. And then when we ORDER BY 2 descending, we’re saying we want to order the results by the second column, the COUNT, from highest to lowest. What we see is there are 15 different food truck brands in this menu table, and they have between 6 and 10 menu items each. Now let’s answer one more question I have, because I can’t resist – When we did our first query, I saw that there was a field called “MENU_TYPE.” What’s the relationship between the food truck’s brand name and the menu type? Are there more menu types than food truck brands, or fewer, or is there a 1:1 mapping? Let’s check this out quickly. All we need to do is revise our query to add MENU_TYPE as another field to group by, and then we group by 1 *and* 2, and order by 3. SELECT TRUCK_BRAND_NAME, MENU_TYPE, COUNT(*) FROM tasty_bytes_sample_data.raw_pos.menu GROUP BY 1,2 ORDER BY 3 DESC; We run this, and see that … it looks like there are still 15 rows, and each truck brand name seems to correspond to a particular menu type. So it appears that if you know the menu type, you know the truck brand name, and vice versa. That’s cool! Okay, the last thing I wanted to show you is that you can always create more worksheets to keep your code organized. If you go to the top of the screen and click on a “plus” sign, you can make a new one. And if you copy over a line of code – like SELECT COUNT(*) AS row_count FROM tasty_bytes_sample_data.raw_pos.menu; You can run a query from that new worksheet. Or you can go back to the main Snowsight menu by clicking on the Projects tab on the left of the screen. Then make sure you’re in the Worksheets section, and you can click the “plus” in the top right corner, and hop into a new worksheet that way. If you scroll to the top of your worksheet tab, and click on the three vertical dots there, you can rename your worksheet to whatever you’d like. I’m going to call mine “Beautiful Blank Worksheet - So Much Possibility.” So there you go! In the last two videos, we learned about the fictional Tasty Bytes dataset, hopped into Snowsight, loaded a worksheet, queried some data, and then learned how to create a new worksheet. Look at us – We’ve only just gotten started, but we’ve already come so far!

2. Let's practice!

Create Your Free Account

or

By continuing, you accept our Terms of Use, our Privacy Policy and that your data is stored in the USA.