select p.productname,
(case when c.Parent-Category-Id is null
then c.category
when c.Parent-Category-Id is not null
then (select category from category where id=c.Parent-Category-Id)end
)as category
from product p inner join category c on p.category=c.id
where c.category not in ('LPG')
Thanks
12 People are following this question.