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.
| Author |
Topic |
|
satish.gorijala
Posting Yak Master
182 Posts |
Posted - 2009-07-08 : 07:04:35
|
| Culture Name AnalysisFREN Freskyn INDI pangupta DUTC Buckskyn GERM Heuschober INDI Dasgupta GERM Lugupta INDI Gergupta GERM Shober SCOT Ruskyn SCOT Arskyn Rules tableRType Rules CultureRLL %gupta INDIRLL %hober GERMRLL %skyn ITALI 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 followsCulture Name AnalysisFREN Freskyn SCOT-2,FREN-1,DUTC-1INDI pangupta INDI-3,GERM-1DUTC Buckskyn SCOT-2,FREN-1,DUTC-1GERM Heuschober INDI-1,GERM-1INDI Dasgupta INDI-3,GERM-1GERM Lugupta INDI-3,GERM-1INDI Gergupta INDI-3,GERM-1GERM Shober INDI-1,GERM-1SCOT Ruskyn SCOT-2,FREN-1,DUTC-1SCOT Arskyn SCOT-2,FREN-1,DUTC-1G. Satish |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
|
|
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 |
 |
|
|
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] |
 |
|
|
|
|
|
|
|