select roomratemin, r.rate_date,i.avail_count from (select MIN(if(r.rack_rate_single < r.rack_rate_double and r.rack_rate_single > 0, r.rack_rate_single, if(r.rack_rate_double > 0, r.rack_rate_double, r.rack_rate_single))) as roomratemin, r.room_id, r.rate_date, r.rack_rate_single, r.rack_rate_double from hotel_room_rate_detail r where htl_id = and r.rate_date>='2022-08-19' and r.rate_date <= '2023-02-15' and (r.rack_rate_single >0 or r.rack_rate_double > 0) group by rate_date,room_id)as r join (select avail_count, room_id,inv_date from hotel_room_inventory where hotel_id = and inv_date between '2022-08-19' and '2023-02-15' and blocked = 'No' and avail_count > 0 ) as i on r.room_id = i.room_id and i.inv_date = r.rate_date GROUP BY rate_date order by rate_date

Query :
select roomratemin, r.rate_date,i.avail_count from (select MIN(if(r.rack_rate_single < r.rack_rate_double and r.rack_rate_single > 0, r.rack_rate_single, if(r.rack_rate_double > 0, r.rack_rate_double, r.rack_rate_single))) as roomratemin, r.room_id, r.rate_date, r.rack_rate_single, r.rack_rate_double from hotel_room_rate_detail r where htl_id = and r.rate_date>='2022-08-19' and r.rate_date <= '2023-02-15' and (r.rack_rate_single >0 or r.rack_rate_double > 0) group by rate_date,room_id)as r join (select avail_count, room_id,inv_date from hotel_room_inventory where hotel_id = and inv_date between '2022-08-19' and '2023-02-15' and blocked = 'No' and avail_count > 0 ) as i on r.room_id = i.room_id and i.inv_date = r.rate_date GROUP BY rate_date order by rate_date

Error Message :
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and r.rate_date>='2022-08-19' and r.rate_date <= '2023-02-15' and (r.rack_rate_s' at line 3

User Type:


Module :

Page Name : index.php

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'and r.rate_date>='2022-08-19' and r.rate_date <= '2023-02-15' and (r.rack_rate_s' at line 3