From the course: Learning Data Analytics Part 2: Extending and Applying Core Knowledge
Understanding queries
From the course: Learning Data Analytics Part 2: Extending and Applying Core Knowledge
Understanding queries
- [Instructor] If you were to Google define the word query, you'll discover that a query is actually a question. We have questions in data all the time, like how many X did we sell? That's an easy query, right? So yes, a query is a question. But in regards to data analysis, it's also a statement created with a tool to answer a question with data. You must identify where that information is stored, and how you will query it, using tools that query to produce the data for the answer. This is why I refer to questions from leadership as ask, and refer to the action of querying data as a query or tool. It's a lot to process, but queries really are nothing more than statements that you create that provide you the data that you need. When we query data, it's a task to be completed with a tool. The way you query in that tool is actually defined by the tool you're using. And you're going to discover that the concepts are universal, but the points and clicks are definitely different based on the tool. Remember that querying is also a process, and that one question can produce multiple queries or segments. There are also different types of queries that you'll use throughout your data experience, and you'll use them based on what issues you're trying to solve and what you need to accomplish to get to the end goal of your task. For most people at the beginning, it's just simple select queries powered by select statements. These select queries are called select queries, because that's what they do, they select data from tables. They're usually defined with just the fields you need to accomplish any given task. This is just like manually removing the noise from the data that we talked about earlier. But you're picking the fields that will help you answer the questions. When you query with multiple tables involved, then you know from experience you have to address the joins and join types. And in databases, these are still called select queries. But in tools like Power Query, for example, you might hear them referred to as merge queries. Then there are queries that you can leverage when you want to create data or copy data, or need to update data. If you need to copy data from one table to another table, this type of query is called an append query. If you need to update data, like changing X to Y, then you're doing what's called an update query. You'll also need to know how to make a query distinct or unique. This is a big time-saver, and sometimes it's an absolute must. A distinct query looks at the fields you have selected, and then gives you a unique list. It's important to note that a distinct or unique statement is more of a property of a select statement versus a type of query, like an update or a PIN. Have you ever done an AutoSum in Excel? Well, we do the same things with queries. These aggregate functions in queries are called total queries. Again, queries are so flexible, and when you learn your data and you know how to join it, and you understand the different types of queries that you might use, there is no data ask that you can't accomplish.