Click here to Skip to main content
15,899,679 members
Home / Discussions / Database
   

Database

 
GeneralRe: Insert within Select Statement Pin
indian14313-Oct-15 10:28
indian14313-Oct-15 10:28 
AnswerRe: Insert within Select Statement Pin
Mycroft Holmes13-Oct-15 22:55
professionalMycroft Holmes13-Oct-15 22:55 
QuestionSort GetChildRow datarow array Pin
BobW99912-Oct-15 2:58
BobW99912-Oct-15 2:58 
AnswerRe: Sort GetChildRow datarow array Pin
Mycroft Holmes12-Oct-15 13:07
professionalMycroft Holmes12-Oct-15 13:07 
GeneralRe: Sort GetChildRow datarow array Pin
BobW99912-Oct-15 17:34
BobW99912-Oct-15 17:34 
GeneralRe: Sort GetChildRow datarow array Pin
Mycroft Holmes12-Oct-15 17:40
professionalMycroft Holmes12-Oct-15 17:40 
SuggestionNeed to Optimize this Query Pin
Member 1205173711-Oct-15 23:33
Member 1205173711-Oct-15 23:33 
QuestionTimeline for Work Completion Pin
macca249-Oct-15 0:48
macca249-Oct-15 0:48 
AnswerRe: Timeline for Work Completion Pin
CHill609-Oct-15 2:12
mveCHill609-Oct-15 2:12 
QuestionMSSQL behavior: I need to round instead of truncation when number scale is exceeded Pin
px058-Oct-15 21:32
px058-Oct-15 21:32 
AnswerRe: MSSQL behavior: I need to round instead of truncation when number scale is exceeded Pin
GuyThiebaut8-Oct-15 23:04
professionalGuyThiebaut8-Oct-15 23:04 
GeneralRe: MSSQL behavior: I need to round instead of truncation when number scale is exceeded Pin
px058-Oct-15 23:26
px058-Oct-15 23:26 
AnswerRe: MSSQL behavior: I need to round instead of truncation when number scale is exceeded Pin
Eddy Vluggen9-Oct-15 1:39
professionalEddy Vluggen9-Oct-15 1:39 
AnswerRe: MSSQL behavior: I need to round instead of truncation when number scale is exceeded Pin
Wombaticus10-Oct-15 8:00
Wombaticus10-Oct-15 8:00 
QuestionSql Server Back-end with Access or Asp.net Front-end Pin
macca247-Oct-15 23:23
macca247-Oct-15 23:23 
AnswerRe: Sql Server Back-end with Access or Asp.net Front-end Pin
CHill608-Oct-15 14:29
mveCHill608-Oct-15 14:29 
AnswerRe: Sql Server Back-end with Access or Asp.net Front-end Pin
Daniel Miller19-Oct-15 14:18
professionalDaniel Miller19-Oct-15 14:18 
Questiondatagrid code Pin
Maristello7-Oct-15 3:47
Maristello7-Oct-15 3:47 
AnswerRe: datagrid code Pin
CHill608-Oct-15 14:25
mveCHill608-Oct-15 14:25 
QuestionSQL server query Pin
Swap96-Oct-15 4:04
Swap96-Oct-15 4:04 
AnswerRe: SQL server query Pin
Richard Andrew x646-Oct-15 7:10
professionalRichard Andrew x646-Oct-15 7:10 
AnswerRe: SQL server query Pin
RNA Team10-Oct-15 8:33
RNA Team10-Oct-15 8:33 
Try this

SQL
DECLARE @T TABLE(ID_NO INT IDENTITY,FIRST_NAME VARCHAR(50), LAST_NAME VARCHAR(50))
INSERT INTO @T VALUES('X','ABC'),('Y','ABC'),('M','PQR'),('N','PQR')
--SELECT * FROM @T
;WITH CTE AS(
            SELECT
      Rn = ROW_NUMBER() OVER(PARTITION BY t2.LAST_NAME ORDER BY (SELECT 1))
                ,t2.LAST_NAME
                + ',' +
                STUFF(( SELECT '-' + t1.FIRST_NAME
                        FROM @T t1
                        WHERE t1.LAST_NAME = t2.LAST_NAME
                        FOR XML PATH(''),TYPE)                        .value('.','NVARCHAR(MAX)'),1,1,'')AS Concat_FirstName
FROM @T t2
)
SELECT
    STUFF(( SELECT '/' + c1.Concat_FirstName
            FROM CTE c1
            WHERE c1.Rn = c2.Rn
            FOR XML PATH(''),TYPE)
            .value('.','NVARCHAR(MAX)'),1,1,'') AS Concat_FirstName
FROM CTE c2 WHERE Rn= 1
GROUP BY c2.Rn


Result

Concat_FirstName
ABC,X-Y/PQR,M-N

Hope this helps
QuestionHOW TO COPY DBF Files in VB.NET Pin
sunil8800891-Oct-15 22:17
sunil8800891-Oct-15 22:17 
AnswerRe: HOW TO COPY DBF Files in VB.NET Pin
phil.o1-Oct-15 23:55
professionalphil.o1-Oct-15 23:55 
AnswerRe: HOW TO COPY DBF Files in VB.NET Pin
Patrice T2-Oct-15 0:56
mvePatrice T2-Oct-15 0:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.