SELECT fl.flight_id, COUNT(s.seat_no) as aircraft_capacity,
SUM(CASE WHEN b.seat_no IS NOT NULL THEN 1 ELSE 0 END) as load,
(SUM(CASE WHEN b.seat_no IS NOT NULL THEN 1 ELSE 0 END)/COUNT(s.seat_no)::float)*100::numeric(10,2)
FROM bookings.flights fl
JOIN bookings.aircrafts a ON fl.aircraft_code = a.aircraft_code
JOIN bookings.seats s ON a.aircraft_code = s.aircraft_code
LEFT JOIN bookings.boarding_passes b ON fl.flight_id = b.flight_id AND s.seat_no = b.seat_no
WHERE fl.flight_no = 'PG0242'
GROUP BY fl.flight_id, a.model
ORDER BY fl.flight_id
// Отправить запрос на получение отзывов
$.ajax({
url: "get_reviews.php",
type: "GET",
success: function(response) {
// Преобразовать полученную строку JSON в массив
var reviews = JSON.parse(response);
// Использовать полученный многомерный массив отзывов
reviews.forEach(function(review) {
console.log("Username: " + review.username);
console.log("Review: " + review.review_text);
console.log("Rating: " + review.rating);
});
}
});