Doesn't make much sense to me. Why is
1001 mobile
the expected output and not
1001 table
. What I try to say is the second column is useless in the output you desire, as no-one know if the customer has 0 or more other products only that, that the customer has that particular product.
that said you can do it with a nested select statement where you take only the first row, so something like this:
SELECT customerno, (select TOP 1 products from myTable where customerno = t.customerno) as products from myTable t group by customerno
However I would think that you should get all the products
(e.g.
1001 mobile, table
) so I would personally do something like this:
SELECT customerno,
REPLACE(RTRIM((SELECT [products] + ' ' FROM myTable
WHERE customerno = t.customerno) FOR XML PATH (''))),' ',', ') AS products
FROM myTable t GROUP BY customerno