March 7, 2006 at 3:11 am
Hi I have a table Product_feature (Product_id, Feature_code)
with rows as
P1, 'F1'
P1, 'F2'
P2, 'F1'
I would like to know how I can get a comparitive feature list for Product P1 and Product P2 something like
Feature Available for P1 Available for P2
'F1' 'Y' 'Y'
F2 'Y' 'N'
-------------------------------------------------
thanks in advance
Rajesh
March 7, 2006 at 3:35 am
Rajesh,
Is this what you want?
--This SQL script is safe to run
--Create table and data
DECLARE @Product_feature TABLE (Product_id VARCHAR(2), Feature_code VARCHAR(2))
INSERT INTO @Product_feature
SELECT 'P1', 'F1'
UNION SELECT 'P1', 'F2'
UNION SELECT 'P2', 'F1'
--Select comparison
SELECT
Feature_code,
MAX(CASE WHEN Product_id = 'P1' THEN 'Y' ELSE 'N' END) AS P1,
MAX(CASE WHEN Product_id = 'P2' THEN 'Y' ELSE 'N' END) AS P2
FROM
@Product_feature
GROUP BY
Feature_code
Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
March 7, 2006 at 3:45 am
This is precisely what I was looking in for.
thanks
Rajesh
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply