November 18, 2008 at 4:26 am
Hi
I am having trouble combine 2 rows of data into 1 and was wondering if someone could help me.
I have a view called "Fees", which contains 4 rows of data as follows,
ID Description Amount
1 Registry Fee £10
1 SM5 £3
5 DMC £5
5 Registry Fee £10
I would like to be able to create another view which groups the data in the "Fees" view depending on the ID so the data will look as follows,
ID Combined
1 Registry Fee £10, SM5 £3
5 DMC £5, Registry Fee £10
So far I have come up with the following (not sure if it helps).
DECLARE @STR VARCHAR(100)
SELECT
@STR = COALESCE(@str + ', ', '') + [Description]
FROM Fees
where
Fees.ID = '1'
Print @STR
Any help will be most appreciated. Thanks
November 18, 2008 at 5:53 am
Take a look at this post, the concept is the same:
http://www.sqlservercentral.com/Forums/Topic602485-1291-1.aspx
If you need help applying this method to your situation, please provide table DDL/sample data as inserts.
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply