troubleshooting Question

join 4 tables group by one of them and sum the rest

Avatar of jsbx
jsbxFlag for Chile asked on
Microsoft SQL ServerASPMicrosoft SQL Server 2005
8 Comments1 Solution435 ViewsLast Modified:
Hello,

I have 4 tables:

DTE                    <- sales main (need to got the date from here)
-----------
id_compra              <- sale id                
fecha_emision          <- date
tipodte                <- kind of transaction  


DTE_DETALLE            <- sales details (need to got UTILIDAD from gere)
-----------
id_compra              <- sale id
codigo                 <- barcode
utilidad               <- money earned


INVENTARIO             <- inventory
----------
codigo                 <- barcode
precio_costo_neto      <- money cost
id_categoria_antigua   <- family id


ADMIN_V4_CATEGORIA     <- product family
------------------
id_categoria           <- family id      
categoria              <- family name


"id_compra" is the same in DTE and DTE_DETALLE
"codigo" is the same in DTE_DETALLE and INVENTARIO
"id_categoria" and "id_categoria_antigua" are the same in INVENTARIO and ADMIN_V4_CATEGORIA tables

I need to select sales (DTE_DETALLE) between 2 given dates (DTE got the date) and end up with this table:

| CATEGORIA (group by this) | PRECIO_COSTO_NETO (sum) | UTILIDAD (sum) |

thank you
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 8 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 8 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