-
avoid using sp
hi,
I have a table like
A B C
--- ------- -----
Tim jones text1
Tim jones text2
....
and I want to group the result by A,B and C(is string) , normaly if C is number you can use Sum() or other aggregate functions.
with out using Store procedure is there any way to achive following result.
result
A B C
--- ------- -----
Tim jones text1text2
...
Thanks
S
-
There isn't a function for this, but you can create your own user defined function and call it inline in a query .... assuming that you are using a database that supports that.
-
Thanks,can you please help me with coding the funtion
-
Please tell us which DBMS you are working with.
-
sql server 2000 enterprise
-
CREATE FUNCTION dbo.udf_ConcatText (@A varchar (50), @B varchar (50)) RETURNS varchar (4000) AS
BEGIN
DECLARE @temp varchar (4000)
SET @temp = ''
SELECT @temp = @temp + ISNULL (C)
FROM yourtable
WHERE A = @A AND B = @B
Return (@temp)
END
GO
And you can use it like this:
SELECT A, B, dbo.udf_ConcatText (A, B)
FROM yourTable
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|