Новичок
Покинул форум
Сообщений всего: 1
Дата рег-ции: Нояб. 2015
Помог: 0 раз(а)
|
PHP:
скопировать код в буфер обмена
$result = $connection->query("select teil, pps, poz from `ZS_v2` where `del` = '0' and `status` != '0' group by teil"); $count = $connection->query("SELECT a.pps, a.teil, a.poz, a.id, SUM(IF(b.status = 1, b.kilk, 0-b.kilk)) AS quantity FROM `Preproduction`.`ZS_v2` AS a LEFT JOIN `Preproduction`.`ZS_v2` AS b ON b.del != '1' and b.perer ='0' AND b.pps = a.pps WHERE a.del = 0 AND a.status != 0 and a.teil = '$row[teil]' GROUP BY a.pps HAVING quantity > 0"); $count2 = $connection->query("SELECT a.pps, a.teil, a.poz, a.id, SUM(IF(b.status = 2, b.kilk, 0-b.kilk)) AS quantity FROM `Preproduction`.`ZS_v2` AS a LEFT JOIN `Preproduction`.`ZS_v2` AS b ON b.del != '1' and b.perer ='1' AND b.pps = a.pps WHERE a.del = 0 AND a.status != 0 and a.teil = '$row[teil]' GROUP BY a.pps HAVING quantity > 0"); $result_2 = $connection->query("SELECT SUM(IF(status = 2, kilk, 0-kilk)) AS quantity, SUM(if(status = 2, 1, 0)) - sum(if(status = 0, 1, 0)) as count FROM `Preproduction`.`ZS_v2` WHERE del != '1' and perer ='1' AND teil = '$row[teil]'"); $result_3 = $connection->query("SELECT SUM(IF(status = 1, kilk, 0-kilk)) AS quantity, SUM(if(status = 1, 1, 0)) - sum(if(status = 0, 1, 0)) as count, part FROM `Preproduction`.`ZS_v2` WHERE del != '1' and perer ='0' AND teil = '$row[teil]'"); }
|