0

I have a simple Interbase SQL Select Group By query:

Select STRINGNAME from STRINGLIST
Group by STRINGNAME

This query returns this result:

STRINGNAME
FirstString
SecondString
ThirdString

and etc.

I would like to have my query return one row that does this in any order:

FirstString,SecondString,ThirdString

or inverted

ThirdString,SecondString,FirstString

How is it possible to do it? I was thinking of a procedure but maybe there is another more simple way?

SovereignSun
  • 184
  • 1
  • 10

2 Answers2

1

I've found the answer myself. Thanks.

Firebird and Interbase have a LIST() aggregate function which does just what I need:

SELECT LIST(DISTINCT STRINGNAME, ',')
FROM STRINGLIST

This works perfectly for Interbase SQL and Firebird SQL

SovereignSun
  • 184
  • 1
  • 10
0

using temp variable you can do this:-

declare @tmp varchar(max)
SET @tmp = ''
select @tmp = @tmp + STRINGNAME + ', ' from STRINGLIST Group by STRINGNAME
select @tmp
anjali
  • 84
  • 6