I'm doing an SQL in which I want to add whose product is similar that is.
I have my sql, I attach them to you.
select distinct cat.Nombre as Categoria, pro2.Nombre as Producto, InventarioInicial, ocd.CostoUnitario
from Inventario as inv2
inner join (
select
inv.ProductoID,
pro.Nombre,
count(inv.ProductoID) as InventarioInicial
from Inventario as inv
inner join Productos as pro on pro.ID = inv.ProductoID
where inv.Consumido <> 1
group by pro.Nombre, inv.ProductoID
) as c2 on c2.ProductoID = inv2.ProductoID
inner join Productos as pro2 on pro2.ID = inv2.ProductoID
inner join Categorias as cat on cat.ID = pro2.CategoriaID
left join OrdenDeCompraDetalles as ocd on ocd.ProductoID = pro2.ID
I would like to add similar products, that is, the CostoUnitario field Whose Product Name is the same, so as not to have duplicates the products with different unit cost. I hope you help me or advise me. Thanks.