Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL for this output?

Status
Not open for further replies.

fixthebug2003

Programmer
Oct 20, 2003
294
US
I have SQL written that give me an output like this:

Col1 Col2 Col3
ST E01 NB01
ST E01 NB02
ST E01 NB03
ST E01 NB04
GM N09 NB01
GM N09 NB02
GM N09 NB03
GM N09 NB04

I need the out put like this:

col1 col2 col3
ST, GM E01,N09 NB01
ST, GM E01,N09 NB02
ST, GM E01,N09 NB03
ST, GM E01,N09 NB04

Is there a way to accomplish this using SQL?



 
Something like this ?[tt]
SELECT A.Col1||','||B.Col1 As col1
,A.Col2||','||B.Col2 As col2
,A.Col3 As col3
FROM yourTable A INNER JOIN yourTable B
ON A.Col3=B.Col3 AND A.Col2<B.Col2[/tt]

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top