By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,514 Members | 1,717 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,514 IT Pros & Developers. It's quick & easy.

multiple cloumns in single row

P: 1
Below query returns row with coma separated column values. I would need some help if it is on primary column and not on ROW_NUMBER() OVER().

http://www.thescripts.com/forum/thread432951.html

WITH source(rn,name) AS (SELECT ROW_NUMBER() OVER() AS rc,
name
from table ),
rec(n,name) AS (SELECT 2,CAST(name AS VARCHAR(2000))
FROM source WHERE rn = 1
UNION ALL
SELECT n+1, rtrim(rec.name) || ',' || rtrim(source.name)
FROM source, rec WHERE n = rn)
SELECT name FROM rec ORDER BY n DESC FETCH FIRST ROW ONLY;

Thanks
Oct 30 '07 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.