How to use this SQL server Statement in Powerbuilder 8 datawindow:
SELECT t1.floor_code,
unit_code=STUFF
(
(
SELECT DISTINCT '-' + CAST(t2.unit_code AS VARCHAR(MAX))
FROM Table2 t2
WHERE t2.company_code = t1.company_code and
t2.office_code = t1.office_code and
t2.ps_contract_hdr_code = t1.ps_contract_hdr_code and
t2.floor_code = t1.floor_code
FOR XML PATH('')
),1,1,''
)
FROM Table1 t1
GROUP BY company_code, floor_code , office_code, ps_contract_hdr_code
Order BY company_code, floor_code , office_code, ps_contract_hdr_code
When you create a new data window,
You have the following options
For your requirement, you can wrap this code in a stored procedure and use option stored procedure