2 min
How to use GROUP BY to concatenate strings in MySQL and SQL Server?
Problem Often when dealing with database records, you might encounter a situation where you want to group records based on a specific column but...
2 min
Problem Often when dealing with database records, you might encounter a situation where you want to group records based on a specific column but...
2 min
Problem You have a table with a column where some rows contain NULL values or empty strings. You want to retrieve rows where this...
2 min
Problem You have a table with multiple records. For each distinct value in one of the columns (i.e., each ‘group by’ group), you want...
2 min
Problem You have a table with multiple rows of data for each unique identifier and you want to concatenate the values of these rows...
2 min
Problem How to escape a single quote in SQL Server, with a solution that is also reproducible in MySQL? For example, let’s try to...
3 min
Problem How to select a random row using SQL? Input employee_id first_name last_name salary 1 John Doe 50000 2 Jane Smith 60000 3 Michael...
2 min
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...
2 min
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...
2 min
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...
2 min
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....
3 min
Problem You have a table with multiple rows of data for each group, and you want to select the last row from each group....
25 min
SQL, short for Structured Query Language is a programming language used to communicate with databases and do various types of Data wrangling operations. This...