salix/db/changes/233801/00-address_getLosesLastYear...

15 lines
332 B
SQL

DELIMITER $$
CREATE OR REPLACE DEFINER=`root`@`localhost` PROCEDURE `vn`.`address_getLoses`()
BEGIN
SELECT t.addressFk , a.nickname, c.name
FROM ticket t
JOIN address a ON a.id = t.addressFk
JOIN client c ON a.clientFk = c.id
WHERE c.typeFk = 'loses'
AND a.isactive = 1
GROUP BY t.addressFk;
END$$
DELIMITER ;