I need to select three columns from two different tables in sql server 2008. i tried below query but its show error like this
error message
Column 'tb_new_product_Name_id.Product_Name' is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.
query
select pn.Product_Name as [Product Name], pn.Product_Id as [Product Id],COUNT(pnd.Product_id)+1 as duplicate_id
from tb_new_product_Name_id as pn,tb_new_product_Name_id_duplicate as pnd
where pn.Product_Name LIKE '%'+@product_name_id+'%'
or (pn.Product_Id like '%'+@product_name_id+'%' and pnd.Product_Id like '%'+@product_name_id+'%' );
where i made mistake ?