I have main table called ‘Employee’ and another slave table called ‘EmployeeTypes’ that has a FK from ‘Employee’.
Each row in ‘Employee’ can have zero or many rows in ‘EmployeeTypes’ and I want to make an SQL Query that returns data of all Employees and each employee row should contain its related data in ‘EmployeeTypes’ (for example column called ‘TypeID’) as a comma separated list, like this:
Meco Beco --- 45 ---- 1,2,3
You can do this by combining a UDF that uses the Coalese method of generating a CSV list, with your standard sql statement.
The udf will look something like:
You then can simply call the udf like so: