Thursday, 9 March 2023

Aggregate Functions

 



Hey there, and welcome to this tutorial on aggregate functions in SQL! Aggregate functions are a powerful tool for data analysis and reporting, and are used to perform calculations on groups of rows in a database table.



What are Aggregate Functions? Aggregate functions are SQL functions that take a collection of rows as input and return a single value as output. The output value is based on some calculation that is performed on the input rows, such as counting the number of rows or calculating the average value of a column.


Common Aggregate Functions: There are several common aggregate functions in SQL, including:

  • COUNT: Counts the number of rows in a table or a group of rows.
  • SUM: Calculates the sum of a numeric column in a table or a group of rows.
  • AVG: Calculates the average value of a numeric column in a table or a group of rows.
  • MAX: Finds the maximum value of a column in a table or a group of rows.
  • MIN: Finds the minimum value of a column in a table or a group of rows.

How to Use Aggregate Functions: Aggregate functions are used in SQL queries with the SELECT statement. Here's an example:

SELECT COUNT(*) FROM customers;

This query would return the total number of rows in the "customers" table.

Here's another example:

SELECT AVG(price) FROM products WHERE category = 'electronics';

This query would return the average price of all products in the "electronics" category.

Common Mistakes and Errors: When using aggregate functions, there are a few common mistakes and errors to watch out for. For example:

  • Dividing by zero: This can happen if you're calculating a ratio and the denominator is zero.
  • Including non-numeric data: If you try to use an aggregate function on a column that contains non-numeric data, you may get an error.

Best Practices: Here are a few best practices to keep in mind when using aggregate functions:

  • Use the GROUP BY statement to group data before aggregating it.
  • Use the HAVING clause to filter data after it has been aggregated.
  • Be careful when using aggregate functions on large data sets, as they can be computationally expensive.

Conclusion: Aggregate functions are a powerful tool for data analysis in SQL. By using functions like COUNT, SUM, AVG, MAX, and MIN, you can perform calculations on groups of rows and gain insights into your data. Remember to use best practices and watch out for common mistakes and errors.

Thursday, 16 February 2023

Kick Start your analytics journey

Not 5 but 6 Steps to summarize your analytics journey

Learning analytics can be a bit daunting for a beginner,

but there are several steps you can take to get started:


  1. Learn the basics of statistics: Statistics is a foundational subject for analytics. You'll need to understand basic concepts like mean, median, standard deviation, and correlation before you can dive deeper into analytics.

  2. Choose an analytics tool: There are many different analytics tools available, including Excel, Python, R, and Tableau, among others. Choose one that you're comfortable with and start practicing.

  3. Get hands-on experience: Practice is key to learning analytics. Start by analyzing sample data sets and working through online tutorials to get a feel for how analytics works in practice.

  4. Join an online community: There are many online communities, like Reddit's r/analytics or LinkedIn's analytics groups, where you can connect with other beginners and experts in the field. These communities are a great place to ask questions and get feedback.

  5. Take online courses: There are many online courses available that cover the basics of analytics, including platforms like Coursera, edX, and Udemy, among others. These courses are a great way to learn from experienced instructors and get a structured approach to learning.

  6. Read industry publications: Keep up with the latest trends and techniques in analytics by reading industry publications, like Harvard Business Review or Analytics Vidhya.

Remember, learning analytics is a journey, and it takes time and practice to become proficient. Don't be afraid to make mistakes and ask questions, and you'll be on your way to becoming an analytics expert in no time!

Sunday, 13 March 2022

Top 5 SQL interview Questions

Top 5 interview questions on SQL 


In this article, we are going to talk about top 5 interview questions that most of you would get in your interviews. 


Preparing for these questions gives you an edge in the interview and you can perform impress your interviewer with your knowledge and your command over writing SQL queries.


Question 1: What is the difference between Char and Varchar?

Question 2: What is the difference between Where and Having Clause?

Question 3: What are aggregate functions? Give some examples.

Question 4: What is the difference between Data definition Language (DDL) and DML (Data Manipulation language)

Question 5: What are different types of joins. Explain each of them


In my next Blog, I will cover the answers to all these questions.



Monday, 30 November 2020

Basic Excel skills for a Data Analyst / Business Analyst- Beginners

 Well, this is for the users who want to grow in their career as data analysts or business analysts or if they simply want to make a career transition to this role.

With a lot of skills mentioned everywhere, this gets confusing for people to concentrate on what should they specifically learn if they want to grow as an analyst or if they want to make a transition to this role.

In this blog, I will simply mention a few important skills that helped me move from a career which was far far different from a business analyst role to transition into a business analyst role in a leading e-commerce firm.

Among all the hi-fi terminologies that you might have heard of - Python, Pandas, Numpy, Regression, Machine Learning, Modelling and the list goes on and on, the most important of them all is Excel. If you have a command over excel you can do wonders at your job. Not only this, when you learn how to play with the data on excel, all the hi-fi terminologies I mentioned before would seem easier to you when you start learning them.

So, without wasting anymore time, lets get straight to the point. Get yourself well versed with the following topics in Excel to kick start your career to the next level

For Basic understanding

1. Data Formats- Learn about the different types of format ex. number, date, time, text


2. Advanced Filtering and sorting techniques

3. Data Formatting: Normal color formatting, Rule/condition based,gradient based etc

4. Charts and graphs: Line Charts, Bar charts, Scatter plot, Histogram plot etc

5. Important Excel Formulas:
    Sumif, Sumifs, countif, countifs, average, If , vlookup, hlookup, match, And, or

6. Pivot: Normal pivot techniques, Pivot based on grouped rows/columns, power pivot

In my later blogs, I will talk in detail on how to learn these skills. what the sources that could help and other bonus concepts

Thanks for now. See you in the next blogs :)





Older Posts

Basic Excel skills for a Data Analyst / Business Analyst- Beginners

 Well, this is for the users who want to grow in their career as data analysts or business analysts or if they simply want to make a career ...