on 06-19-2006 10:51 AM
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
Hi Torbjörn,
How about creating a temporary table in which you would select all the distinct baseref values for the selected invoice and then making the coalesce selection against this temporary table instead of inv1 ?
Henry
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
How did you use the temporary table?
Can you write your code here.
I am also getting repeated data values in my query output. I want to save that query output into one temporary table and than want to use the SELECT DISTINCT on that temporary table. I am searching on forum madely to do that but can't find the perfect help. It will be nice if you can help me in that.
Thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
12 | |
11 | |
6 | |
5 | |
4 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.