SELECT a.Id AS id, a.benamning, a.dagar FROM module_bokning_produkter AS a INNER JOIN module_bokning_datumregler AS c ON a.Id = c.produktid AND (20171000 BETWEEN c.fromdate AND c.todate) RIGHT JOIN module_bokning_produkt_rumstyp AS f ON a.Id = f.`produktid` AND a.typ > 0 AND a.publicerad = 1 INNER JOIN module_bokning_kalender AS d ON f.rumstypid = d.rumstypid AND d.`datum`='2017-10-00' AND d.antal > 0 INNER JOIN module_bokning_priser AS e ON a.Id = e.`produktid` AND f.`rumstypid` = d.rumstypid AND e.ankomstdag = 5 AND e.pris > 0 GROUP BY a.ID ORDER BY a.typ, a.sortering, a.benamning