# get_query_portfolio_lijst_met_tag SELECT DISTINCT( p.id ), p.*, YEAR( p.contract_datum ) AS year FROM edn_portfolio p INNER JOIN edn_portfolio_lijst pl ON pl.id = p.lijst_id AND pl.status = 0 INNER JOIN edn_tag_link tl ON tl.portfolio_id = p.id WHERE EXISTS ( SELECT * FROM edn_tag_link tl WHERE tl.portfolio_id = p.id AND tl.tag_id = '119' ) GROUP BY p.nr ORDER BY contract_datum DESC