Skip to content
Advertisement

SQL Query to join multiple tables

I have 4 tables that I need to connect in order to get the reports that I need. But I’m confused on how to write the query. Below are the sample of the tables:

Client Table

JavaScript

Consultant

JavaScript

Perm

JavaScript

Temp

JavaScript

The end result of the report that I want to show is something like this:

JavaScript

I’m trying to use the LEFT OUTER JOIN, but I don’t get the result that I want. Can anyone help me to figure out the query?

Advertisement

Answer

this is a simple outer join query with count and group by,just join your client table with the related ones and count only the distinct associations

JavaScript

Fiddle Demo

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement