This Enables us to get the content of multiple rows as a single row value. ex: select name from abc result: Arun Anand Amit . . . This can be displayed as: arun,anand,amit...
Example:
SELECT
MAX( CASE seq WHEN 1 THEN empname ELSE '' END ) + ',' +
MAX( CASE seq WHEN 2 THEN empname ELSE '' END ) + ',' +
MAX( CASE seq WHEN 3 THEN empname ELSE '' END ) + ',' +
MAX( CASE seq WHEN 4 THEN empname ELSE '' END ) AS [emp name]
FROM ( SELECT p1.empname,
( SELECT COUNT(*)
FROM EmpMast p2
WHERE p2.empname <= p1.empname )
FROM EmpMast p1 ) D (empname,seq)
AttachmentsSql Rows Concatenate (34459-28341-sqlConcatenateRows.txt)
|
No responses found. Be the first to respond and make money from revenue sharing program.
|