How to Use Join and String_agg in Microsoft SQL Server
In this article, we’ll look at how to use join on more than two tables and aggregate the result using the function STRING_AGG()
in Microsoft SQL Server.
If you don’t know about Microsoft SQL Server, I’ll briefly explain to you what it is.
😃
What is Microsoft SQL Server?
Microsoft SQL Server is a Relational Database Management System that revolutionized how businesses handle data. It helps to store and manage data.
If you’re familiar with other relational database management systems such as MySQL, or PostgreSQL then picking up Microsoft SQL Server is easy.
I’m running on the default instance of SQL server.
Now, let’s consider a problem.
Problem
Let’s say we have three tables namely Employee
, Project
and EmployeeProject
. The below image is the relational database design:
The problem is to get all the employee details and their corresponding projects.