On Tue, Feb 17, 2009 at 11:16 PM, Joanne Pham <[email protected]> wrote:
> Hi All,
> I have the select statement as below
> sqlite> select remoteId, hostName , remoteWXType from remoteWXTable order by
> hostName;
> and the output is below:
>
> 1|HostName1-T432|2
> 2|HostName2-T421|2
> 3|HostName3-XP|2
> 4|HostName3-XP|2
>
> But I would like the sql statement to return as below:
> (HostName3 has two remoteId so I want to return as one row but two different
> remoteId as below)
> 1|HostName1-T432|2
> 2|HostName2-T421|2
> 3,4|HostName3-XP|2
> Can you please help to change the sql statement to return the above result
> set.
> Thanks,
> JP
>
No problem...
SELECT group_concat(remoteId, ','), hostName, remoteWXType
FROM remoteWXTable
GROUP BY hostName; -- or remoteWXType ...?
I think group_concat is only supported in moderately recent versions
of sqlite3, so make sure to not be using something 1 or 2 years old.
-David
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users