SQL-Part5- Groupby & Partition by

Yi-Ling L.
2 min readMay 23, 2022

This is my note to record my path on what I learned from SQL. If you find some content wrong, please forgive me.

For me, SQL is a language that gives me a better way to extract the data I need to sort out raw data from the database management system.

I started my learning journey in Feb 2021, but I stopped, and now I am taking my journey back. 6 months later, I had done nothing, and without good knowledge of query and another computer language, I got stocked and also to find an intern. I decided to master some specific skills of SQL to manipulate data better for business analytics.

I am a beginner at learning to use SQL, this kind of tooling. Therefore I sometimes encounter several issues that I cannot resolve by myself. Due to my worst memories, I decided to jot down all I have been learning in case I forget all of them.

When you have one column(or one field) with one group you want to filter out, you use GROUP BY; Otherwise, you use Partition to sort out multiple groups in one field(one column).

Imagine there is a table called Employee, with ten columns, and each column contains different values that may exist in the same pattern that consists of multiple groups. Let’s take an example, a column called Job titles. After you observe it, you find some patterns, such as sales, engineering, manager, and customer services. Most of the time, two or three people are always working for the same title rather than one. I guess you know what I gonna say. Then what if I want to know how many people work for each job title in the column? shall I use group by to sort it out? No, you cannot; you need a Partition clause.

To be continued….

--

--

Yi-Ling L.

Hi I am Yi-Ling. I am a Tableau Business Intelligence Analyst.