troubleshooting Question

group by errors

Avatar of jsbx
jsbxFlag for Chile asked on
Microsoft SQL ServerMicrosoft SQL Server 2005Microsoft SQL Server 2008
6 Comments1 Solution375 ViewsLast Modified:
sqlstring = "SELECT a.id_categoria, a.categoria, SUM(i.precio_costo_neto * dd.cantidad) AS precio_costo_neto, SUM(dd.utilidad) AS utilidad FROM ADMIN_V4_CATEGORIA a INNER JOIN INVENTARIO i ON a.id_categoria = i.id_categoria_antigua INNER JOIN DTE_DETALLE dd ON i.codigo = dd.codigo INNER JOIN DTE d ON dd.id_compra = d.id_compra WHERE (d.fechaemision >= '" & fecha_inicio & "' and d.fechaemision<= '" & fecha_termino & "') and (d.tipodte='33' or d.tipodte='30' or d.tipodte='35' or d.tipodte='39') GROUP BY a.id_categoria, a.categoria order by a.categoria"

I just want to group by a.id_categoria, but if i remove the a.categoria from the order by clause it gives me an error and i need to use it.

Also i would like to know if this "GROUP BY a.id_categoria, a.categoria order by a.categoria" will give me different results that if i only group by id_Categoria


thanks.
ASKER CERTIFIED SOLUTION
Ken Butters

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros