0

I have a table that contains the following type of data

Device     IDs
ABC        123
ABC        234
ABC        345
XYZ        123
XYZ        999

My SQL String that I was given (sorry I know nothing about SQL) was

SELECT*
From Name123456789

When I import data into the tracking application I have it produces errors because ABC and XYZ are not viewed as a Parents to the IDs but instead they are viewed each as their own individual records.

Is there a way with SQL to break it out so that Device would equal ABC and IDs would equal 123, 234, 345?

Desired Output ALL RECORDS BUT HAVE THE FOLLOWING format for just those two fields as there are other fields too:

Device     IDs
ABC        123, 234, 345
XYZ        123, 999
Nathan
  • 107
  • 8

1 Answers1

0

I have (once, a while ago) done something like this in Oracle SQL using the wm_concat function. The syntax there would be something like

select device,
       wm_concat(IDs) IDs
from tablename
group by device;

I don't use SQL server but this answer appears to show how to do the same in SQL Server.

Alternatively you could add an order by device then put the info from each device together in the application layer.

Community
  • 1
  • 1
Adam
  • 6,539
  • 3
  • 39
  • 65