complex 492 not foundSELECT c2.complex_id, 'EUR' AS base_currency, c2.complex_name, c2.complex_directory, c2.no_buildings, c2.management_fee, MIN(CASE WHEN p.sold = 0 THEN p.start_price ELSE NULL END) AS price_min, MAX(CASE WHEN p.sold = 0 THEN p.end_price ELSE NULL END) AS price_max, COUNT(CASE WHEN p.sold = 1 THEN p.sold ELSE NULL END) AS sold_properties, COUNT(p.property_id) AS total_properties, c2.area_name, c2.beach, c2.shopping, c2.city, c2.facility_ids, c2.facilities, c2.year, c2.no_floors, c2.lat, c2.lng, c2.area_id, c2.area_name, c2.information, c2.area_directory, c2.resort_id, c2.resort_name, c2.resort_directory, c2.video_url as complex_video, c2.parking, c2.site_id, c2.site_name, c2.site_directory, MIN(p.floor_size_min) AS floor_size_min, MAX(p.floor_size_max) AS floor_size_max, MIN(p.plot_size_min) AS plot_size_min, MAX(p.plot_size_max) AS plot_size_max, MIN(p.garden_size_min) AS garden_size_min, MAX(p.garden_size_max) AS garden_size_max, MIN(p.toilets_min) AS toilets_min, MAX(p.toilets_max) AS toilets_max, MIN(p.balconies_min) AS balconies_min, MAX(p.balconies_max) AS balconies_max, MIN(p.terraces_min) AS terraces_min, MAX(p.terraces_max) AS terraces_max, MIN(p.bedrooms_min) AS bedrooms_min, MAX(p.bedrooms_max) AS bedrooms_max, MIN(p.bathrooms_min) AS bathrooms_min, MAX(p.bathrooms_max) AS bathrooms_max, MIN(p.livingrooms_min) AS livingrooms_min, MAX(p.livingrooms_max) AS livingrooms_max, MAX(p.updated_at) AS updated_at, MIN(p.diff_date) AS diff_date, MIN(p.sold) AS sold FROM (SELECT * FROM (SELECT complex.complex_id, complex.name as complex_name, complex.year, complex.no_floors, complex.no_buildings, complex.management_fee, complex.directory AS complex_directory, complex.lat, complex.lng, complex.beach, complex.shopping, complex.city, complex.video_url, area.area_id, area.area_name, area.information, area.area_directory, resort.resort_id, resort.resort_name, resort.resort_directory, IFNULL((SELECT '1' FROM complex_facility WHERE complex_id = complex.complex_id AND facility_id = 12), 0) AS parking, site.site_id, site.site_name, site.site_directory FROM complex INNER JOIN (SELECT txt.txt_id AS area_id,txt_lang.title AS area_name, txt_lang.directory AS area_directory, txt.resort_id AS resort_id, txt_lang.content as information FROM txt,txt_lang WHERE txt.txt_id=txt_lang.txt_id AND txt_lang.lang_id=6) AS area INNER JOIN (SELECT txt.txt_id AS resort_id,txt_lang.title AS resort_name, txt_lang.directory AS resort_directory, txt.site_id AS site_id FROM txt,txt_lang WHERE txt.txt_id=txt_lang.txt_id AND txt_lang.lang_id=6) AS resort INNER JOIN (SELECT txt.txt_id AS site_id, txt_lang.title AS site_name, txt_lang.directory AS site_directory FROM txt,txt_lang WHERE txt.txt_id=txt_lang.txt_id AND txt_lang.lang_id=6) AS site WHERE complex.active='1' AND complex.directory!='' AND area.area_id=complex.area_id AND resort.resort_id=area.resort_id AND site.site_id=resort.site_id) AS c1 LEFT JOIN (SELECT complex_facility.complex_id as cid,GROUP_CONCAT(CONVERT(facility_lang.facility_id,CHAR(8)) SEPARATOR ',') as facility_ids,GROUP_CONCAT(facility_lang.facility SEPARATOR ', ') as facilities FROM facility_lang,complex_facility WHERE facility_lang.facility_id=complex_facility.facility_id AND facility_lang.lang_id='6' GROUP BY complex_facility.complex_id) as f ON f.cid = c1.complex_id ) AS c2, (SELECT property.complex_id, property.short_name, property.name as property_name, property.floor_size_min, property.floor_size_max, property.bedrooms_min, property.bedrooms_max, property.livingrooms_min, property.livingrooms_max, property.plot_size_min, property.plot_size_max, property.garden_size_min, property.garden_size_max, property.toilets_min, property.toilets_max, property.balconies_min, property.balconies_max, property.terraces_min, property.terraces_max, property.bathrooms_min, property.bathrooms_max, property.updated_at, DATEDIFF(now(),property.updated_at) AS diff_date, property.price_min AS start_price, GREATEST(property.price_min,property.price_max) AS end_price, property.property_id, property.video_url, property.directory AS property_directory, property.type_id AS type_id, (SELECT menu FROM txt_lang WHERE txt_id=property.type_id AND lang_id='6') AS type, property.note_id1, (SELECT sentence FROM sentence_lang WHERE sentence_id=property.note_id1 AND lang_id='6') AS note, e.equipment_ids, e.equipments, t.theme_ids, t.themes, IFNULL((SELECT '1' FROM theme_property WHERE property_id=property.property_id AND theme_id='11'), 0) AS discounted, IFNULL((SELECT '1' FROM theme_property WHERE property_id=property.property_id AND theme_id='3'), 0) AS sold FROM property LEFT JOIN (SELECT property_equipment.property_id AS pid,GROUP_CONCAT(CONVERT(equipment_lang.equipment_id,CHAR(8)) SEPARATOR ',') as equipment_ids,GROUP_CONCAT(equipment_lang.equipment SEPARATOR ', ') as equipments FROM equipment_lang,property_equipment WHERE equipment_lang.equipment_id=property_equipment.equipment_id AND equipment_lang.lang_id='6' GROUP BY property_equipment.property_id) AS e ON e.pid=property.property_id LEFT JOIN (SELECT theme_property.property_id as pid,GROUP_CONCAT(CONVERT(txt_lang.txt_id,CHAR(8)) SEPARATOR ',') as theme_ids,GROUP_CONCAT(txt_lang.title SEPARATOR ', ') as themes,GROUP_CONCAT(txt.extra_information SEPARATOR ', ') as theme_style FROM txt,txt_lang,theme_property WHERE txt.txt_id=theme_property.theme_id AND txt_lang.txt_id=theme_property.theme_id AND txt_lang.lang_id='6' GROUP BY theme_property.property_id) AS t ON t.pid=property.property_id WHERE property.active='1' ) as p WHERE p.complex_id=c2.complex_id AND c2.complex_id='492' GROUP BY c2.complex_id