9 -- there must be a better way to do this.......
14 itemcharvalue(item_id, 'BRAND') as item_brand,
15 itemcharvalue(item_id, 'PRODUCTCATEGORY') as item_productcategory,
18 CASE WHEN (addr_country IS NULL OR addr_country = '') THEN
22 END AS cohist_country,
24 ROUND( COALESCE(SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitprice, cohist_shipdate)),0),2) as ship_value,
25 ROUND(COALESCE(SUM(cohist_qtyshipped),0),0) as ship_qty
32 cust_id = cohist_cust_id
37 cntct_id = cust_cntct_id
42 addr_id = cntct_addr_id
46 itemsite_id = cohist_itemsite_id
50 itemsite_item_id = item_id
54 -- (cohist_invcdate BETWEEN '$cStartDate' AND '$cEndDate')
55 (cohist_invcdate BETWEEN '2011-01-01' AND '2012-01-01')
58 item_id,item_number,item_descrip1,addr_country
66 itemcharvalue(item_id, 'BRAND') as item_brand,
67 itemcharvalue(item_id, 'PRODUCTCATEGORY') as item_productcategory,
71 -- previous year qty sales
73 COALESCE(SUM(cohist_qtyshipped),0)
77 (cohist_itemsite_id = itemsite__id)
79 (cohist_invcdate BETWEEN '$pStartDate' AND '$pEndDate')
84 SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitprice, cohist_shipdate))
89 (cohist_itemsite_id = itemsite__id)
91 (cohist_invcdate BETWEEN '$pStartDate' AND '$pEndDate')
96 COALESCE(SUM(cohist_qtyshipped),0)
102 cust_id = cohist_cust_id
107 cntct_id = cust_cntct_id
112 addr_id = cntct_addr_id
118 (cohist_itemsite_id = itemsite__id)
120 (cohist_invcdate BETWEEN '$cStartDate' AND '$cEndDate')
122 CASE WHEN (addr_country IS NULL OR addr_country = '') THEN
128 ) as cur_ship_{$country}
131 SUM(cohist_qtyshipped * currToBase(cohist_curr_id, cohist_unitprice, cohist_shipdate))
137 cust_id = cohist_cust_id
142 cntct_id = cust_cntct_id
147 addr_id = cntct_addr_id
152 (cohist_itemsite_id = itemsite__id)
154 (cohist_invcdate BETWEEN '$cStartDate' AND '$cEndDate')
156 CASE WHEN (addr_country IS NULL OR addr_country = '') THEN
162 ) as cur_total_{$country}
172 itemsite_item_id = item_id