Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Not knowing how to use stuff

Author  Topic 

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-07-08 : 07:04:35
Culture Name Analysis
FREN Freskyn
INDI pangupta
DUTC Buckskyn
GERM Heuschober
INDI Dasgupta
GERM Lugupta
INDI Gergupta
GERM Shober
SCOT Ruskyn
SCOT Arskyn

Rules table

RType Rules Culture
RLL %gupta INDI
RLL %hober GERM
RLL %skyn ITAL


I need to update Analysis column based on the rules i have in rules table. If i give rule '%gupta', the analysis column will filled with data INDI-3,GERM-1 for all Names ends with 'gupta'.

The output should be as follows

Culture Name Analysis
FREN Freskyn SCOT-2,FREN-1,DUTC-1
INDI pangupta INDI-3,GERM-1
DUTC Buckskyn SCOT-2,FREN-1,DUTC-1
GERM Heuschober INDI-1,GERM-1
INDI Dasgupta INDI-3,GERM-1
GERM Lugupta INDI-3,GERM-1
INDI Gergupta INDI-3,GERM-1
GERM Shober INDI-1,GERM-1
SCOT Ruskyn SCOT-2,FREN-1,DUTC-1
SCOT Arskyn SCOT-2,FREN-1,DUTC-1



G. Satish

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-08 : 08:20:36
see concatenate records without UDF


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

satish.gorijala
Posting Yak Master

182 Posts

Posted - 2009-07-08 : 08:38:48
Hi, Can you give the query for my requirement. Here inner join need to use with rules table. i am not knowing how to use stuff here. Offcourse i am new to use these command. Bit confusing by seeing the link which you have given.


quote:
Originally posted by khtan

see concatenate records without UDF


KH
[spoiler]Time is always against us[/spoiler]





G. Satish
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-07-08 : 08:59:12
[code]
SELECT Culture, [Name],
Analysis = STUFF((SELECT ',' + x.Culture + '-' + CONVERT(varchar(10), COUNT(*))
FROM Culture x
INNER JOIN Rules y ON x.Name LIKE y.Rules
WHERE y.Culture = c.Culture
GROUP BY x.Culture
ORDER BY COUNT(*) DESC, x.Culture DESC
FOR XML PATH('')), 1, 1, '')
FROM Culture c
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -