[SQL] Grouping data from right table Turn Back
2018-02-22 17:41:33
SELECT z.delivery_type, IF(dt.detail IS NULL or dt.detail = '', pt.status_desc, dt.detail) as DT, count(*) CNT, z.price FROM(SELECT d.pack_type, d.delivery_type, d.priceFROM postmail_header hRIGHT JOIN postmail_detail d on d.post_hid=h.post_hidWHERE h.doc_status=3 and d.delivery_type IN (18,19,20)) zLEFT JOIN mst_extra_charge dt on dt.extra_id=z.delivery_typeLEFT JOIN mst_status_type pt on pt.id=z.pack_typeGROUP BY z.pack_type, z.delivery_type, z.price