Skip to Content
Former Member
Jun 19, 2006 at 09:51 AM

SQL query problem, listing all deliveries linked to an invoice


Hi I'm trying to write a query that returns all the deliveries linked to an invoice as a single commaseparated result.

This query gets all the links from every line as a commaseparated result but I want to remove the duplicate entries, eg. where/how do I insert the distinct clause?

DECLARE @EmployeeList varchar(350)

SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') +

( T1.baseref )

FROM oinv T0 inner join inv1 T1 on T0.DocEntry = T1.DocEntry

where T0.docnum = 119229 and T1.baseref <> ''

SELECT @EmployeeList

Thanks in advance for all help