Link to home
Start Free TrialLog in
Avatar of Mike Eghtebas
Mike EghtebasFlag for United States of America

asked on

How to query using derived table and multi CTEs...

Having temp table #t contain:
Product  ProdType
A            x
B            x
B            xx
C            x
D            x
D            xx
E            x

Question: Using derived table and also CTEs (2nd solution), How to produce result like:
ProdType  ProdType
B            x
B            xx
D            x
D            xx

These solutions basically ignore products with single ProdType?

T-SQL to build #t:
create table #t(Product char(1), ProdType varchar(2));
Insert into #t(Product, ProdType) Values
('A', 'x')
, ('B', 'x')
, ('B', 'xx')
, ('C', 'x')
, ('D', 'x')
, ('D', 'xx')
, ('E', 'x');

Select * From #t;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Mike Eghtebas
Mike Eghtebas
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Mike Eghtebas

ASKER

Note to experts, This question was added to be referenced by an article to build temp table #t.

Thanks.