Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Using TOP in a function

$
0
0

I would like to modify this function to concatenate/return just the TOP 6 values. I have tried many things. Can anyone help? Thanks!

CREATE FUNCTION [dbo].[Rpt_ConcatSecondaryDxIds] (@VisitNumber varchar(20))
RETURNS varchar(max)
AS
BEGIN
DECLARE @DxList varchar(max);
SELECT @DxList = COALESCE(@DxList + ', ', '') + DX_ID FROM DX where VISIT_NO =@VisitNumber and Dx_Type <> 0  and Dx_Type <> 1 ORDER BY DX_ID;
RETURN (@DxList);
END
GO


Linda


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>