Drop a Query

# September 18, 2023

## Central Limit Theorem – A Deep Dive into Central Limit Theorem and its Significance in Statistics

Statistics offers a vast array of principles and theorems that are foundational to how we understand data. Among them, the Central Limit Theorem (CLT) stands as one of the most important. Let’s dive deeper into the concept, ensuring that all points are covered and clarified. In this blog post we will learn: Simple Explanation of …

## How to remove duplicate rows in MySQL?

Problem Given a table in MySQL, how do you remove duplicate rows? Input first_name last_name email John Doe [email protected] Jane Smith [email protected] John Doe [email protected] Bob Johnson [email protected] Alice Williams [email protected] Jane Smith [email protected] Try Hands-On: Fiddle Create Input Table: Gist Desired Output first_name last_name email John Doe [email protected] Jane Smith [email protected] Bob Johnson [email protected]

## How to split values to multiple rows in SQL?

Problem How to split values to multiple rows in SQL? Input To illustrate this problem, let’s create a sample input table named “Sales” with some data. The table will have two columns: “Date” and “Amount.” id vals 1 value1,value2,value3 2 value4,value5 3 value6 Try Hands-On: Fiddle Create Input Table: Gist Desired Output id split_value 1 …

## How to calculate running total in SQL Server?

Problem You need to calculate a running total in SQL Server and provide a solution that is also reproducible in MySQL. Input To illustrate this problem, let’s create a sample input table named “Sales” with some data. The table will have two columns: “Date” and “Amount.” Date Amount 2023-09-01 100.00 2023-09-02 75.50 2023-09-03 50.25 2023-09-04 …

## How to insert into a table or update if exists in MySQL?

Problem You need to calculate a running total in SQL Server and provide a solution that is also reproducible in MySQL. Input employee_id first_name last_name salary 1 John Doe 50000.00 2 Jane Smith 60000.00 3 Bob Johnson 55000.00 Try Hands-On: Fiddle Desired Output On inserting a new row, if the entry already exists, it should …

## How to do a FULL OUTER JOIN in MySQL?

Problem How to do a FULL OUTER JOIN in MySQL? Let’s create two example tables, employees and departments, and insert some data into them. Input select * from employees; employee_id employee_name department_id 1 John 1 2 Jane 2 3 Bob 4 Alice 1 select * from departments; department_id department_name 1 HR 2 Finance 3 Marketing …

## How to get the rows which have the max value for a column for each group in another column in SQL?

Problem You want to find the rows that have the maximum value for a specific column within each group in another column. For example, you have a table with data about products and their prices, and you want to find the most expensive product in each category. Input product_id product_name category_id price 1 Product A …

## How to concatenate text from multiple rows into a single text string in MySQL?

Problem You need to concatenate text from multiple rows into a single text string, for every group present in another column using SQL. For example, from the employee_comments table, concatenate all comments from a given employee in one row. See the input and the desired output below. Input employee_id comment_text 1 John is a hard …

Course Preview