<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: lateef sulaiman</title>
    <description>The latest articles on Forem by lateef sulaiman (@thedatamayor).</description>
    <link>https://forem.com/thedatamayor</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1782542%2F848a5b3b-384a-42f2-a2c0-0611467cc987.png</url>
      <title>Forem: lateef sulaiman</title>
      <link>https://forem.com/thedatamayor</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/thedatamayor"/>
    <language>en</language>
    <item>
      <title>Mastering SQL: Understanding Group By and Order By</title>
      <dc:creator>lateef sulaiman</dc:creator>
      <pubDate>Sat, 27 Jul 2024 08:38:51 +0000</pubDate>
      <link>https://forem.com/thedatamayor/mastering-sql-understanding-group-by-and-order-by-48bm</link>
      <guid>https://forem.com/thedatamayor/mastering-sql-understanding-group-by-and-order-by-48bm</guid>
      <description>&lt;p&gt;&lt;strong&gt;Introduction&lt;/strong&gt;&lt;br&gt;
In this article, I'll walk you through two of the most important concepts in SQL: GROUP BY and ORDER BY. Mastering these concepts will make query writing much easier and more efficient for you. We will explore how to use them, when to use them, and where they can be applied effectively. By the end of this article, you'll have a clear understanding of these concepts and be able to use them proficiently in your SQL queries.&lt;/p&gt;

&lt;p&gt;GROUP BY is an essential tool for Data Analysis. GROUP BY groups rows with the same values in specified columns into summary rows. It is mostly used with ‘Aggregate Functions’ like ‘COUNT’, ‘SUM’, ‘AVG’, ‘MAX’, and ‘MIN’.&lt;br&gt;
Think of GROUP BY as sorting things into different categories. Imagine you have a big box filled with balls of different colors and sizes. To organize them, you decide to separate them into smaller boxes based on their color. You would end up with a box of blue balls, a box of red balls, and so on. In this scenario, you are grouping the balls by their color. Similarly, you could also organize the balls by their size, placing all the small balls in one box, the medium balls in another, and the large balls in yet another. This is exactly what GROUP BY does in SQL: it organizes your data into categories based on one or more columns.&lt;br&gt;
Example&lt;br&gt;
Suppose I have a table named 'Student_Data' with the following data:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Name&lt;/th&gt;
&lt;th&gt;Gender&lt;/th&gt;
&lt;th&gt;Birth_Month&lt;/th&gt;
&lt;th&gt;Age&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Mike&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;January&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Alex&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;January&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Anita&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;April&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Gbenga&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;February&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Amanda&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;June&lt;/td&gt;
&lt;td&gt;14&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Folarin&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;February&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Lateef&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;September&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Oyiza&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;September&lt;/td&gt;
&lt;td&gt;10&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Mark&lt;/td&gt;
&lt;td&gt;Male&lt;/td&gt;
&lt;td&gt;May&lt;/td&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Valerie&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;June&lt;/td&gt;
&lt;td&gt;13&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Chioma&lt;/td&gt;
&lt;td&gt;Female&lt;/td&gt;
&lt;td&gt;April&lt;/td&gt;
&lt;td&gt;15&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;I can group these data by Gender, Birth_Month, Age and even Name.&lt;/p&gt;

&lt;p&gt;Example Queries and Results:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Group by Gender
```
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;SELECT Gender &lt;br&gt;
FROM Student_Data &lt;br&gt;
GROUP BY Gender;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result: 

Gender
------
|Male   |
|Female |

2. 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SELECT Birth_Month &lt;br&gt;
FROM Student_Data &lt;br&gt;
GROUP BY Birth_Month;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result:

Birth_Month
-----------
|January|
|April|
|February|
|June|
|September|
|May|

3.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SELECT name &lt;br&gt;
FROM Student_Data&lt;br&gt;
GROUP BY name;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result:

Name
--------
|Mike|
|Alex|
|Anita|
|Gbenga|
|Amanda|
|Folarin|
|Lateef|
|Oyiza|
|Mark|
|Valerie|
|Chioma|

**Group By and Aggregate Functions**
Now, let's talk about GROUP BY and Aggregate Functions. These are used to aggregate data, providing summarized information from your dataset.

Still going by the above scenario with the colored balls, if we are interested in knowing the details of each box, we can use what we call Aggregate Functions. How does the Aggregate Function work? With Aggregate Functions, we can determine the number of balls in each box, the biggest ball in each box, the smallest ball in each box, the average size of the balls in each box, and the total size of the balls in each box.

In SQL, Aggregate Functions like COUNT, MAX, MIN, AVG, and SUM are used with the GROUP BY clause to perform these calculations.

From the Student_Data above, we can use GROUP BY and Aggregate Functions to calculate the number of students by gender, the average age of students, the age of the oldest student, the age of the youngest student, and the sum of the students' ages by gender.

Example Queries and Results:

- Number of students by gender: We can use the COUNT function to know the number of students by gender.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SELECT Gender, COUNT(*) AS Number_of_Students&lt;br&gt;
FROM Student_Data&lt;br&gt;
GROUP BY Gender;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result:

| Gender | Number_of_Students 
|------- | ------  
| Male   |  6   
| Female |  5   
|    |          



- Average Age of Students by Gender: We can use the 'AVG' function to calculate the average age of students by gender.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SELECT Gender, AVG(Age) AS Average_Age&lt;br&gt;
FROM Student_Data&lt;br&gt;
GROUP BY Gender;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result: 

| Gender | Average_Age
| ------ | -------
| Male   | 12.5
| Female | 12.8
|        | 


- Oldest Student by Gender: We can use the 'MAX' function to find the age and name of the Oldest Student.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SELECT Gender, MAX(Age) AS Oldest_Student&lt;br&gt;
FROM Student_Data&lt;br&gt;
GROUP BY Gender;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result: 

| Gender | Oldest_Student
| ------ | ----------
| Male   | 15
| Female | 15
|        | 


- Sum of Students' ages by gender: We can use the 'SUM' function to calculate the total ages of Students by Gender.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SELECT Gender, SUM(Age) AS Total_Ages&lt;br&gt;
FROM Student_Data&lt;br&gt;
GROUP BY Gender;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
Result:


| Gender | Total_Ages
| ------ | -------
| Male   | 75
| Female | 64

By using 'GROUP BY' with AGGREGATE FUNCTIONs we can easily get summarized insights, helping us to better analyze and understand our data. 

**ORDER BY**
Now that we understand how to use 'GROUP BY' to organize data into categories, let's talk about 'ORDER BY'.'ORDER BY' in SQL is used to arrange data in ascending or descending order based on the values specified. 

Think of 'ORDER BY' as arranging a list of names alphabetically or arranging a group of students by their height.

Example: Considering our 'Student_Data' table. We can decide to list the students by their ages in ascending order.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SELECT Name,Age &lt;br&gt;
FROM Student_Data&lt;br&gt;
ORDER BY Age;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result:

| Name    | Age
|------   | -----
| Lateef  | 10
| Oyiza   | 10
| Mark    | 11
| Mike    | 12
| Anita   | 12
| Folarin | 13
| Valerie | 13
| Alex    | 14
| Amanda  | 14
| Gbenga  | 15
| Chioma  | 15 

**Combining GROUP BY and ORDER BY**
We can combine 'GROUP BY' and 'ORDER BY' to get more insight from our 'Student_Data' Table.

We can find the average age of students for each gender and then list these gender groups in descending order of their average age.

Example Query:

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;SELECT Gender, AVG(Age) AS Average_Age&lt;br&gt;
FROM Student_Data&lt;br&gt;
GROUP BY Gender&lt;br&gt;
ORDER BY Average_Age DESC;&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Result:

| Gender | Average_Age
| ------ | ---------
| Female | 12.8
| Male   | 12.5

In the query above:

- The 'GROUP BY' clause groups the student by their Gender 

- The 'AVG' function calculates the average age for each gender group.

- The 'ORDER BY' clause sorts the result by the average age in descending order. 

By combining 'GROUP BY' and 'ORDER BY' we can sort our grouped data, making it easier to analyze and understand the results. 

**CONCLUSION**
Understanding how to use 'GROUP BY' and 'ORDER BY' in SQL is crucial for effective Data Analysis. These powerful tools allow us to organize, summarize and sort data in meaningful ways. 'GROUP BY' can help us  categorize our data into groups, Aggregate Functions can help us extract valuable insights from these groupings. The ORDER BY clause then helps us to sort and present our results in an ordered fashion, making our data easier to interpret and analyze.

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>sqlserver</category>
      <category>datascience</category>
    </item>
    <item>
      <title>Solving the SQL Murder Mystery: A Step-by-Step Guide</title>
      <dc:creator>lateef sulaiman</dc:creator>
      <pubDate>Tue, 16 Jul 2024 12:30:03 +0000</pubDate>
      <link>https://forem.com/thedatamayor/solving-the-sql-murder-mystery-a-step-by-step-guide-29cc</link>
      <guid>https://forem.com/thedatamayor/solving-the-sql-murder-mystery-a-step-by-step-guide-29cc</guid>
      <description>&lt;p&gt;Maybe I should consider a career as a detective! In this article, I am going to walk you through how I solved a mystery murder case from SQL Murder Mystery. Let us dive into the crime scene and uncover the truth step by step.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Mystery&lt;/strong&gt;&lt;br&gt;
A crime has taken place and the detective needs your help. The detective gave you the crime scene report but you somehow lost it. You vaguely remember that the crime was a murder that occurred sometime on Jan. 15, 2018, and that it took place in SQL City. Let's start by retrieving the corresponding crime scene report from the police department’s database. A schema was provided; &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faco7yrwlbauuvtxh1n4g.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Faco7yrwlbauuvtxh1n4g.png" alt="schema" width="800" height="391"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Initial Clues&lt;/strong&gt;&lt;br&gt;
I only remembered the type of crime, the city, and the date. So, I started with this query:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM crime_scene_report 
WHERE type = 'murder' 
AND city = 'SQL City' 
AND date = '20180115';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here’s what I found:&lt;br&gt;
"Security footage shows that there were 2 witnesses. The first witness lives at the last house on "Northwestern Dr". The second witness named Annabel lives somewhere on "Franklin Ave""&lt;/p&gt;

&lt;p&gt;Great! So We have two witnesses. The first one lives at the last house on Northwestern Dr, and the second one, Annabel, lives on Franklin Ave.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding the First Witness&lt;/strong&gt;&lt;br&gt;
To identify the first witness, I run this query:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM person 
WHERE address_street_name = 'Northwestern Dr' 
ORDER BY address_number DESC 
LIMIT 1;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From this query, I was able to identify &lt;strong&gt;Morty Schapiro&lt;/strong&gt; with person_id 14887 and license_id 118009 as my first witness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding the Second Witness&lt;/strong&gt;&lt;br&gt;
For the second witness, Annabel, I ran:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM person 
WHERE name LIKE 'Annabel%' 
AND address_street_name = 'Franklin Ave';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From this query, I was able to get my second witness &lt;strong&gt;Annabel Miller&lt;/strong&gt; with person_id 16371 and license_id 490173.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Gathering Witness Statements&lt;/strong&gt;&lt;br&gt;
Next, I needed to find out what each witness saw. I run a query to know what Morty Schapiro witnessed:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM interview 
WHERE person_id = '14887';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Morty's statement: I heard a gunshot and then saw a man run out. He had a "Get Fit Now Gym" bag. The membership number on the bag started with "48Z". Only gold members have those bags. The man got into a car with a plate that included "H42W".&lt;/p&gt;

&lt;p&gt;Now, let’s run a query to get Annabel Miller's statement:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM interview 
WHERE person_id = '16371';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Annabel's statement: I saw the murder happen and I recognized the killer from my gym when I was working out last week on January the 9th.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Identifying the Killer&lt;/strong&gt;&lt;br&gt;
From the statements above, I know the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;The murderer is a "Get Fit Now Gym" gold member.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The membership number starts with "48Z".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The car plate includes "H42W".&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;The murderer was at the gym on January 9th.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;First, I checked for gym check-ins on January 9th with this query:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM get_fit_now_check_in 
WHERE check_in_date = '20180109' 
AND membership_id LIKE '48Z%';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I got two results with membership_id 48Z7A and 48Z55. Both are gold members, so I need to narrow it down using the car plate information.&lt;/p&gt;

&lt;p&gt;Narrowing Down the Suspects&lt;br&gt;
First, I retrieved the license details for both suspects:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM person 
WHERE id IN (28819, 67318);


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I got two result from running the query above: Jeremy Bowers with license_id 423327 and Joe Germuska with license_id 173289.&lt;/p&gt;

&lt;p&gt;Next, I checked their car plates:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM drivers_license 
WHERE id IN (423327, 173289);


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From my result, I was able to identify Jeremy Bowers as the Murderer.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7jhu4ezyjxte2vyhs49l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7jhu4ezyjxte2vyhs49l.png" alt="Murder Mystery" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Real Mastermind&lt;/strong&gt;&lt;br&gt;
Upon further investigation, I found that Jeremy Bowers was hired by a woman with distinct characteristics. Let’s run a query to see his statement: &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM interview 
WHERE person_id = '67318';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Jeremy's statement: I was hired by a woman with a lot of money. I don't know her name but I know she's around 5'5" (65") or 5'7" (67"). She has red hair and she drives a Tesla Model S. I know that she attended the SQL Symphony Concert 3 times in December 2017.&lt;/p&gt;

&lt;p&gt;Using this information, I searched for the woman:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM drivers_license 
WHERE hair_color = 'red' 
AND gender = 'female' 
AND car_make = 'Tesla' 
AND car_model = 'Model S';


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I got 3 results from this, all with the same height as described by Jeremy. From Jeremy's statement the mastermind attended SQL Symphony Concert thrice. &lt;br&gt;
I run a query to check for the person_id on the person table.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM person
WHERE license_id in (202298,291182,918773);


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;I got the license_id and name of the 3 possible mastermind from the query above; Red korb with id 78881, Regina George with id 90700 and Miranda Priestly with id 99716.&lt;/p&gt;

&lt;p&gt;Finally, I run a query to check their attendance at the SQL Symphony Concert, to see who attended thrice;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

SELECT * FROM facebook_event_checkin 
WHERE person_id IN (78881, 90700, 99716);


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;From my query, I was able to get that The mastermind is Miranda Priestly with person_id 99716, who attended the concerts three times.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7t1fhbs3mwe5sdnkbbl9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F7t1fhbs3mwe5sdnkbbl9.png" alt="Mastermind" width="800" height="449"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
The murderer is Jeremy Bowers, but the mastermind behind the crime is Miranda Priestly. This was a thrilling case to solve, combining SQL queries with logical deduction. It was an exciting journey to catch the real villain behind the murder.&lt;/p&gt;

&lt;p&gt;Would you like to try solving it yourself? Head over to SQL Murder Mystery and put your detective skills to the test!&lt;/p&gt;

</description>
      <category>sql</category>
      <category>database</category>
      <category>datascience</category>
      <category>howto</category>
    </item>
  </channel>
</rss>
