2 queries , not a big deal i think | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

2 queries , not a big deal i think

I have a query which join 5 tables say my result is Warehouse ProductName Features Price Manf
I just need to make some analysis and need to select any 5 features
from Features column for each productname. There can be 10 – 50
features mentioned in the table with features.
Say my result it like only for productname and features column
which come from diff tables. Here I am getting more than 5 features
I need to reduce that to 5 for each. So how do I do this.
Productname Features
AAAAA 12
AAAAA 145
AAAAA 23
AAAAA 34234
AAAAA 234234
AAAAA 32234
AAAAA 134234
AAAAA 21
AAAAA 14
AAAAA 556
BBBBB 19
BBBBB 23
BBBBB 6
BBBBB 1
BBBBB 2
BBBBB 11
BBBBB 15
BBBBB 12
BBBBB 6
BBBBB 4
Also very important this need to be done is how do i avoid repititions
and do the cross- tab join and make only one row for one product name
and get the result like this
Productname Features
AAAAA 12, 45, 234, 256, 25677, 24223……..
BBBBB 12,121, 144, 58885, 8888, 99999…..
CCCCC 111, 144, 2333, 22333, 22221…….
Refer this
http://sqljunkies.com/WebLog/amachanic/archive/2004/11/10/5065.aspx?Pending=true Madhivanan Failing to plan is Planning to fail
]]>