Recent m-am ciocnit de asa o problema: Aveam tabela Items cu structura urmatoare: id int,name varchar(100) unde valorile in cimpul id si respectiv name se repetau. Problema consta in a extrage lista de id-uri unicale unde name-ul sa constaie din suma de name-uri delimitate prin ",". Mai jos va propun o solutie:
CREATE FUNCTION getName (@latlng varchar(510) )
RETURNS varchar(4000)
AS
BEGIN
declare @t as varchar(2000)
--SET @latlng='48.2016667|27.4158333'
SET @t = ''
select top 4 @t = @t + ' ' + full_name_nd from geocode_md_unicode1 where fc='P' and lat+'|'+long=@latlng
return @t
END
select latlng,dbo.getName(latlng) as nume1 from (
select lat+'|'+long as latlng from geocode_md_unicode as t1 where fc='P'
group by lat+'|'+long) as t2
Niciun comentariu:
Trimiteți un comentariu