Avatar of talahi
talahi
 asked on

Sql query displays multiple records on a single line.

Trying to create a sql query that takes records from a table and displays the records on one line as shown in example below.


 

IDIDENTIDENT_IDTYPECITYSTATE
19YoungURDA1234USRChicagoIL
19YoungURDA4321MODEChicagoIL






IDIDENTIDENT_ID TYPE
CITYSTATE
19Young;19YoungURDA;URDA1234;4321USR;MODEChicago;Chicago IL;IL
SQLOracle Database

Avatar of undefined
Last Comment
slightwv (䄆 Netminder)

8/22/2022 - Mon
Bill Prew

Are there only two rows in the data table?  If not is there some grouping logic to decide what rows get combined on each single row of the displayed data?  Seems like if you want to combine many rows into a single line of the report it's quickly going to get too large.

»bp
Scott Pletcher

Which specific version of SQL are you on?  SQL 2016 or later?  Or earlier than SQL 2016?
talahi

ASKER
Oracle 19 db. The starting table is a Temp table that I've inserted data in to make this task easier. The final solution will be a pl/sql procedure. I guess when implemented with real data it could be more than 2 records in the temp table.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
ASKER CERTIFIED SOLUTION
slightwv (䄆 Netminder)

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
talahi

ASKER
I thought there might be a query that could make this easier. Otherwise my plan is to write a plsql procedure that loops though the number of records and use a couple temp tables to place to data in a results table as specified. 
slightwv (䄆 Netminder)

>>and use a couple temp tables to place to data in a results table as specified

Words of advice:
As SOON as that idea pops into your head, IMMEDIATELY think:  NO!!!!!

Sure, over the years I have used them myself.  BUT only in very rare instances and I knew what I was doing.

Way to often in life when I've come across them, they were 100% unnecessary and were slower than native SQL.