Click here to Skip to main content
15,920,111 members
Home / Discussions / Database
   

Database

 
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 
GeneralRe: HOW TO COPY DBF Files in VB.NET Pin
sunil8800893-Oct-15 21:50
sunil8800893-Oct-15 21:50 
Questionreturn the results from Query union the external proc in DB2 Pin
sudevsu30-Sep-15 8:49
sudevsu30-Sep-15 8:49 
QuestionDatabase relationship for tables Pin
maugonza30-Sep-15 8:43
maugonza30-Sep-15 8:43 
AnswerRe: Database relationship for tables Pin
Jörgen Andersson1-Oct-15 2:12
professionalJörgen Andersson1-Oct-15 2:12 
SuggestionRe: Database relationship for tables Pin
Nathan Minier1-Oct-15 7:15
professionalNathan Minier1-Oct-15 7:15 
QuestionMSaccess query to access random value from database Pin
Member 1202314130-Sep-15 4:50
Member 1202314130-Sep-15 4:50 
QuestionMusic Database Pin
morrism3530-Sep-15 2:30
morrism3530-Sep-15 2:30 
AnswerRe: Music Database Pin
Richard MacCutchan30-Sep-15 3:05
mveRichard MacCutchan30-Sep-15 3:05 
QuestionQuery is not producing the correct results(SOLVED) Pin
samflex28-Sep-15 5:45
samflex28-Sep-15 5:45 
AnswerRe: Query is not producing the correct results Pin
Richard Deeming28-Sep-15 6:22
mveRichard Deeming28-Sep-15 6:22 
GeneralRe: Query is not producing the correct results Pin
samflex28-Sep-15 7:32
samflex28-Sep-15 7:32 
QuestionMove GROUP_CONCAT's comma values to columns Pin
Jassim Rahma22-Sep-15 22:03
Jassim Rahma22-Sep-15 22:03 
Questionpostgresql database issues Pin
Member 1191972221-Sep-15 22:09
Member 1191972221-Sep-15 22:09 
AnswerRe: postgresql database issues Pin
Richard MacCutchan21-Sep-15 22:50
mveRichard MacCutchan21-Sep-15 22:50 

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.