Menu

Selva Prabhakaran

Selva is an experienced Data Scientist and leader, specializing in executing AI projects for large companies. Selva started machinelearningplus to make Data Science / ML / AI accessible to everyone. The website enjoys 4 Million+ readership. His courses, lessons, and videos are loved by hundreds of thousands of students and practitioners.

How to remove duplicate rows in MySQL

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 remove duplicate rows in MySQL? Read More »

How to split values to multiple rows in SQL

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 split values to multiple rows in SQL? Read More »

How to calculate running total in SQL Server

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 calculate running total in SQL Server? Read More »

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

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 insert into a table or update if exists in MySQL? Read More »

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 get the rows which have the max value for a column for each group in another column in SQL? Read More »

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 …

How to concatenate text from multiple rows into a single text string in MySQL? Read More »

SQL Window Functions Exercises

SQL Window Functions Exercises – Practice to perfection

SQL window functions is considered a ‘hard’ concept in SQL. This set of exercises is designed to challenge your SQL muscle and help internalize data wrangling using window functions in SQL. The questions are of three levels of difficulty: Easy, Intermediate and Hard. If you haven’t read the tutorial yet, read SQL Window Functions – …

SQL Window Functions Exercises – Practice to perfection Read More »

SQL Window Functions

SQL Window Functions – Made simple and intuitive

SQL window functions is one of the advanced concepts, understanding which will give you the ability to do complex data wrangling and transformations in SQL. In this guide, we will intuitively understand how window functions work in a way you will never forget. Don’t memorize anything, just read through and you will clearly understand how …

SQL Window Functions – Made simple and intuitive Read More »

SQL Tutorial

SQL Tutorial – A Simple and Intuitive Guide to the Structured Query Language

SQL, short for Structured Query Language is a programming language used to communicate with databases and do various types of Data wrangling operations. This is an essential skillset for any type of Data related jobs. In this tutorial, let’s get started with the basics of SQL. 1. Why you should learn SQL? First, let’s understand …

SQL Tutorial – A Simple and Intuitive Guide to the Structured Query Language Read More »

Cook’s Distance for Detecting Influential Observations

Cook’s distance is a measure computed to measure the influence exerted by each observation on the trained model. It is measured by building a regression model and therefore is impacted only by the X variables included in the model. What is Cooks Distance? Cook’s distance measures the influence exerted by each data point (row / …

Cook’s Distance for Detecting Influential Observations Read More »

Course Preview

Machine Learning A-Z™: Hands-On Python & R In Data Science

Free Sample Videos:

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science

Machine Learning A-Z™: Hands-On Python & R In Data Science