<dtml-comment>
title:
connection_id:erp5_sql_connection
max_rows:1000
max_cache:100
cache_time:0
class_name:ZSQLBrain
class_file:zsqlbrain.py
</dtml-comment>
<params>delivery_uid
resource_uid
variation_text</params>
SELECT
	SUM(movement.target_quantity) AS target_quantity
FROM
	catalog AS container_cell, movement
WHERE
	movement.delivery_uid = <dtml-sqlvar delivery_uid type="int">
AND
	movement.has_cell_content = 0
AND
	container_cell.uid = movement.uid
AND
	(container_cell.portal_type = "Container Cell" OR container_cell.portal_type = "Container Line")
<dtml-if resource_uid>
AND movement.resource_uid = <dtml-sqlvar resource_uid type="int">
</dtml-if>
<dtml-if variation_text>
AND movement.variation_text = "<dtml-var variation_text>"
</dtml-if>