Avatar of Aleks
Aleks
Flag for United States of America

asked on 

Stuff data into one record

I have the query below, that displays the results like this:

results
What I need in the results is something like:

 lastnm                            firstnm              licensenum            licensestate
 Perez/Mucino               Juan/Aleks        423323/1234           Texas/Florida

Which is basically putting the results of both records and stuffing them into one record separated by a  '/'  sign.

How can I do this ?

I am using MS SQL 2008R2 and classic ASP.

Here is my current query which returns two or more rows (rarely more than two). I would probably be happy if it takes the top two records and stuffs them into one separated by '/'

SELECT   b.MaidenNm AS lastnm,
        b.MailStr AS firstnm,
        b.MajFldStudy AS licensenum,
        b.Pob licensestate
FROM    dbo.Atts AS a
        INNER JOIN Users b ON a.UserId = b.UserId
        LEFT JOIN dbo.FirmAddresses AS c ON c.Id = b.FirmAddressIdcon
WHERE   b.UserType = 'attorney'
        AND a.Xfer2Forms = 1
        AND a.CaseId = 11318
ORDER BY a.Ordernumatts ,
        b.MailStr;

Open in new window

Web DevelopmentMicrosoft SQL Server 2008SQL

Avatar of undefined
Last Comment
Anthony Perkins

8/22/2022 - Mon