Delivery_zGetTotal.zsql 923 Bytes
Newer Older
Jean-Paul Smets's avatar
Jean-Paul Smets committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
<dtml-comment>
title:
connection_id:MySQL
max_rows:1000
max_cache:100
cache_time:0
class_name:
class_file:
</dtml-comment>
<params>uid
resource_uid
variation_text</params>
SELECT
	SUM(quantity) AS inventory,
	SUM(quantity) AS total_quantity,
	SUM(total_price) AS total_price,
	SUM(target_quantity) AS target_total_quantity,
	SUM(target_total_price) AS target_total_price,
	AVG(price) AS average_price
FROM movement, catalog
WHERE
	movement.delivery_uid = <dtml-sqlvar uid type="int">
<dtml-if resource_uid>AND	(<dtml-in resource_uid> movement.resource_uid = <dtml-sqlvar sequence-item type="int"><dtml-if sequence-end><dtml-else> OR </dtml-if></dtml-in>)
</dtml-if><dtml-if variation_text>AND	movement.variation_text = <dtml-sqlvar variation_text type="string">
</dtml-if>
AND	movement.is_accountable = 1
AND	catalog.portal_type <> "Container"
AND	catalog.portal_type <> "Simulation Movement"
AND	catalog.uid = movement.uid