UPDATE cust_zone_sales k
FROM
(
SELECT 1420 AS main_zone_id, 17 AS zone_no, COUNT(*) AS sales_count,
(SUM(usd_amount) + SUM(euro_amount) ) AS sales_sum
FROM new_cust_table a
INNER JOIN new_dealer_table b
ON a.prodid = b.prodid
ON a.tran_area_id = b.tran_area_id
AND a.main_zone_id = b.main_zone_id
WHERE a.main_zone_id = 1265
AND a.zone_no = 48
AND zone_status_flag = 'F' AND proddescid = 5
) M
SET k.sales_count = m.sales_count
AND k.sales_sum = m.sales_sum
WHERE
k.main_zone_id=m.main_zone_id AND
k.zone_no= m.zone_no
Thanks,
Venkat
↧