Bookmarks

Yahoo Gmail Google Facebook Delicious Twitter Reddit Stumpleupon Myspace Digg

Search queries

w2ksp4.exe, WwwxxXdbf, procmail "FROM_MAILER" patch, Use of assignment to $[ is deprecated at /usr/local/sbin/apxs line 86. , wwwxxx vim, mysql closing table and opening table, 800c5000, setgid operation not permitted, pciehp: acpi_pciehprm on IBM, WWWXXX.DBF

Links

XODOX
Impressum

#1: Select mit joins und group by

Posted on 2007-11-26 14:04:45 by Mike

Guten Tag,

versuche gerade mit einem Select erforderliche Daten zu erhalten. Mein
Problem ist, das ich zus=E4tzlich einen join auf die Tabelle
orders_products_purchase eingef=FCgt habe und in der where Klausel auf
opp.order_state =3D '0' pr=FCfe. Falls die Tabelle
orders_products_purchase jetzt mehr als ein Datensatz enth=E4lt, stimmt
die Summe im Feld demand_quantity erwartungsgem=E4ss nicht mehr. Gibt es
eine M=F6glichkeit, dieses Problem zu umgehen?

select o.orders_id,
op.orders_products_id, op.products_id,
sum( op.products_quantity ) as demand_quantity,
p.products_quantity as stock_quantity,
pts.supplier_id,
po.purchase_id,
pop.purchase_pos_id, pop.products_quantity as order_quantity
from orders as o
join orders_products as op
on op.orders_id =3D o.orders_id
join orders_products_purchase as opp
on opp.orders_products_id =3D op.orders_products_id
left join products_to_supplier as pts
on pts.products_id =3D op.products_id
left join supplier as s
on s.supplier_id =3D pts.supplier_id
left join address_book as a
on a.address_book_id =3D s.address_book_id
left join products as p
on p.products_id =3D op.products_id
left join purchase_orders as po
on po.supplier_id =3D pts.supplier_id
and po.purchase_state < '1'
left join purchase_orders_pos as pop
on pop.purchase_id =3D po.purchase_id
and pop.products_id =3D op.products_id
where ( o.paid =3D '2' or o.release =3D '1' )
and o.cancel =3D '0'
and opp.order_state =3D '0'
group by op.products_id, pts.supplier_id
order by op.products_name, pts.supplier_id


Besten Dank f=FCr jeden Hinweis

Mike

Report this message