
SELECT SUM(`aux`.`Passenger_Amount`) AS `Amount`,
    `aux_pk`.`Package_Name`,
    SUM(IF(`Month` = 1 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Enero`,
    SUM(IF(`Month` = 2 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Febrero`,
    SUM(IF(`Month` = 3 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Marzo`,
    SUM(IF(`Month` = 4 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Abril`,
    SUM(IF(`Month` = 5 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Mayo`,
    SUM(IF(`Month` = 6 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Junio`,
    SUM(IF(`Month` = 7 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Julio`,
    SUM(IF(`Month` = 8 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Agosto`,
    SUM(IF(`Month` = 9 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Septiembre`,
    SUM(IF(`Month` = 10 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Octubre`,
    SUM(IF(`Month` = 11 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Noviembre`,
    SUM(IF(`Month` = 12 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Diciembre`,
    SUM(IF(`Month` = 1 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Enero`,
    SUM(IF(`Month` = 2 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Febrero`,
    SUM(IF(`Month` = 3 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Marzo`,
    SUM(IF(`Month` = 4 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Abril`,
    SUM(IF(`Month` = 5 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Mayo`,
    SUM(IF(`Month` = 6 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Junio`,
    SUM(IF(`Month` = 7 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Julio`,
    SUM(IF(`Month` = 8 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Agosto`,
    SUM(IF(`Month` = 9 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Septiembre`,
    SUM(IF(`Month` = 10 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Octubre`,
    SUM(IF(`Month` = 11 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Noviembre`,
    SUM(IF(`Month` = 12 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Diciembre`,
    SUM(IF(`Month` = 1 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Enero`,
    SUM(IF(`Month` = 2 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Febrero`,
    SUM(IF(`Month` = 3 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Marzo`,
    SUM(IF(`Month` = 4 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Abril`,
    SUM(IF(`Month` = 5 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Mayo`,
    SUM(IF(`Month` = 6 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Junio`,
    SUM(IF(`Month` = 7 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Julio`,
    SUM(IF(`Month` = 8 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Agosto`,
    SUM(IF(`Month` = 9 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Septiembre`,
    SUM(IF(`Month` = 10 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Octubre`,
    SUM(IF(`Month` = 11 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Noviembre`,
    SUM(IF(`Month` = 12 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Diciembre`,
    SUM(IF(`Month` = 1 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Enero`,
    SUM(IF(`Month` = 2 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Febrero`,
    SUM(IF(`Month` = 3 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Marzo`,
    SUM(IF(`Month` = 4 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Abril`,
    SUM(IF(`Month` = 5 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Mayo`,
    SUM(IF(`Month` = 6 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Junio`,
    SUM(IF(`Month` = 7 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Julio`,
    SUM(IF(`Month` = 8 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Agosto`,
    SUM(IF(`Month` = 9 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Septiembre`,
    SUM(IF(`Month` = 10 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Octubre`,
    SUM(IF(`Month` = 11 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Noviembre`,
    SUM(IF(`Month` = 12 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Diciembre`,
    SUM(IF(`Month` = 1 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Enero`,
    SUM(IF(`Month` = 2 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Febrero`,
    SUM(IF(`Month` = 3 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Marzo`,
    SUM(IF(`Month` = 4 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Abril`,
    SUM(IF(`Month` = 5 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Mayo`,
    SUM(IF(`Month` = 6 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Junio`,
    SUM(IF(`Month` = 7 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Julio`,
    SUM(IF(`Month` = 8 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Agosto`,
    SUM(IF(`Month` = 9 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Septiembre`,
    SUM(IF(`Month` = 10 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Octubre`
FROM `t_package` `aux_pk`
LEFT JOIN
(
    SELECT  `b`.`Id_Booking`,
            `bt`.`Id_BookingTour`,
            `bt`.`Id_Package`,
            `p`.`Package_Name`,
            COUNT(DISTINCT `btp`.`Id_Passenger`) AS `Passenger_Amount`,
            `b`.`Booking_DateConfirm`,
            YEAR(`b`.`Booking_DateConfirm`) AS `Year`,
            MONTH(`b`.`Booking_DateConfirm`) AS `Month`,
            DAY(`b`.`Booking_DateConfirm`) AS `Day`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 1, 0) AS `ReservaWeb`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 0, 1) AS `NotReservaWeb`,
            IF(`u`.`User_Type` = 2, 0, IF(`b`.`Booking_InPerson` = 1, `b`.`Booking_Type`, 8)) AS `Type`,
            `bt`.`Id_Tour`
    FROM `t_booking_tour` `bt`
    INNER JOIN `t_booking` `b` ON `b`.`Id_Booking` = `bt`.`Id_Booking`
    INNER JOIN `t_user` `u` ON `u`.`Id_User` = `b`.`Id_User`
    INNER JOIN `t_package` `p` ON `p`.`Id_Package` = `bt`.`Id_Package`
    INNER JOIN `t_passenger` `ps` ON `ps`.`Id_Booking` = `b`.`Id_Booking`
    INNER JOIN `t_booking_tour_passenger` `btp` ON `btp`.`Id_Passenger` = `ps`.`Id_Passenger`
    WHERE `b`.`Booking_DateConfirm` BETWEEN '2021-01-01 00:00:00' AND '2025-12-31 23:59:59'
    AND   `b`.`Booking_Status` IN (2, 3)
    GROUP BY `b`.`Id_Booking`, `p`.`Id_Package`
    ORDER BY `b`.`Booking_DateConfirm`
) `aux` ON `aux_pk`.`Id_Package` = `aux`.`Id_Package`
GROUP BY `aux_pk`.`Id_Package`
ORDER BY `Amount` DESC, `aux_pk`.`Package_Name` ASC













SELECT SUM(`aux`.`Price`) AS `Price`,
    `aux_pk`.`Package_Name`,
  SUM(IF(`Month` = 1 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Ene`,
  SUM(IF(`Month` = 2 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Feb`,
  SUM(IF(`Month` = 3 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Mar`,
  SUM(IF(`Month` = 4 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Abr`,
  SUM(IF(`Month` = 5 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `May`,
  SUM(IF(`Month` = 6 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Jun`,
  SUM(IF(`Month` = 7 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Jul`,
  SUM(IF(`Month` = 8 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Ago`,
  SUM(IF(`Month` = 9 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Sep`,
  SUM(IF(`Month` = 10 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Oct`,
  SUM(IF(`Month` = 11 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Nov`,
  SUM(IF(`Month` = 12 AND `Year` = 2021, `aux`.`Price`, NULL)) AS `Dic`,
    SUM(IF(`Month` = 1 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2022, `aux`.`Price`, NULL)) AS `Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2023, `aux`.`Price`, NULL)) AS `Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2024, `aux`.`Price`, NULL)) AS `Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2025, `aux`.`Price`, NULL)) AS `Oct`
FROM `t_package` `aux_pk`
LEFT JOIN
(
    SELECT  `b`.`Id_Booking`,
            `bt`.`Id_BookingTour`,
            `bt`.`Id_Package`,
            `p`.`Package_Name`,
            COUNT(DISTINCT `btp`.`Id_Passenger`) AS `Passenger_Amount`,
            SUM(`btp`.`BookingTourPassenger_Price`) AS `Price`,
            `b`.`Booking_DateConfirm`,
            YEAR(`b`.`Booking_DateConfirm`) AS `Year`,
            MONTH(`b`.`Booking_DateConfirm`) AS `Month`,
            DAY(`b`.`Booking_DateConfirm`) AS `Day`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 1, 0) AS `ReservaWeb`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 0, 1) AS `NotReservaWeb`,
            IF(`u`.`User_Type` = 2, 0, IF(`b`.`Booking_InPerson` = 1, `b`.`Booking_Type`, 8)) AS `Type`
    FROM `t_booking_tour` `bt`
    INNER JOIN `t_booking` `b` ON `b`.`Id_Booking` = `bt`.`Id_Booking`
    INNER JOIN `t_user` `u` ON `u`.`Id_User` = `b`.`Id_User`
    INNER JOIN `t_package` `p` ON `p`.`Id_Package` = `bt`.`Id_Package`
    INNER JOIN `t_passenger` `ps` ON `ps`.`Id_Booking` = `b`.`Id_Booking`
    INNER JOIN `t_booking_tour_passenger` `btp` ON `btp`.`Id_Passenger` = `ps`.`Id_Passenger`
    WHERE `b`.`Booking_DateConfirm` BETWEEN '2021-01-01' AND '2025-10-23'
    AND   `b`.`Booking_Status` IN (2, 3)
    GROUP BY `b`.`Id_Booking`, `p`.`Id_Package`
    ORDER BY `b`.`Booking_DateConfirm`
) `aux` ON `aux_pk`.`Id_Package` = `aux`.`Id_Package`
GROUP BY `aux_pk`.`Id_Package`
ORDER BY `Price` DESC, `aux_pk`.`Package_Name` ASC




SELECT SUM(`aux`.`Passenger_Amount`) AS `Amount`,
    `aux_pk`.`Package_Name`,
    COUNT(IF(`Month` = 1 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Enero`,
	COUNT(IF(`Month` = 2 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Febrero`,
	COUNT(IF(`Month` = 3 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Marzo`,
	COUNT(IF(`Month` = 4 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Abril`,
	COUNT(IF(`Month` = 5 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Mayo`,
	COUNT(IF(`Month` = 6 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Junio`,
	COUNT(IF(`Month` = 7 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Julio`,
	COUNT(IF(`Month` = 8 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Agosto`,
	COUNT(IF(`Month` = 9 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Septiembre`,
	COUNT(IF(`Month` = 10 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Octubre`,
	COUNT(IF(`Month` = 11 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Noviembre`,
	COUNT(IF(`Month` = 12 AND `Year` = 2021, `aux`.`Id_Booking`, NULL)) AS ` Diciembre`,
    COUNT(IF(`Month` = 1 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Enero`,
	COUNT(IF(`Month` = 2 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Febrero`,
	COUNT(IF(`Month` = 3 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Marzo`,
	COUNT(IF(`Month` = 4 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Abril`,
	COUNT(IF(`Month` = 5 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Mayo`,
	COUNT(IF(`Month` = 6 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Junio`,
	COUNT(IF(`Month` = 7 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Julio`,
	COUNT(IF(`Month` = 8 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Agosto`,
	COUNT(IF(`Month` = 9 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Septiembre`,
	COUNT(IF(`Month` = 10 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Octubre`,
	COUNT(IF(`Month` = 11 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Noviembre`,
	COUNT(IF(`Month` = 12 AND `Year` = 2022, `aux`.`Id_Booking`, NULL)) AS ` Diciembre`,
	COUNT(IF(`Month` = 1 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Enero`,
	COUNT(IF(`Month` = 2 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Febrero`,
	COUNT(IF(`Month` = 3 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Marzo`,
	COUNT(IF(`Month` = 4 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Abril`,
	COUNT(IF(`Month` = 5 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Mayo`,
	COUNT(IF(`Month` = 6 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Junio`,
	COUNT(IF(`Month` = 7 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Julio`,
	COUNT(IF(`Month` = 8 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Agosto`,
	COUNT(IF(`Month` = 9 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Septiembre`,
	COUNT(IF(`Month` = 10 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Octubre`,
	COUNT(IF(`Month` = 11 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Noviembre`,
	COUNT(IF(`Month` = 12 AND `Year` = 2023, `aux`.`Id_Booking`, NULL)) AS ` Diciembre`,
	COUNT(IF(`Month` = 1 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Enero`,
	COUNT(IF(`Month` = 2 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Febrero`,
	COUNT(IF(`Month` = 3 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Marzo`,
	COUNT(IF(`Month` = 4 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Abril`,
	COUNT(IF(`Month` = 5 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Mayo`,
	COUNT(IF(`Month` = 6 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Junio`,
	COUNT(IF(`Month` = 7 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Julio`,
	COUNT(IF(`Month` = 8 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Agosto`,
	COUNT(IF(`Month` = 9 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Septiembre`,
	COUNT(IF(`Month` = 10 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Octubre`,
	COUNT(IF(`Month` = 11 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Noviembre`,
	COUNT(IF(`Month` = 12 AND `Year` = 2024, `aux`.`Id_Booking`, NULL)) AS ` Diciembre`,
	COUNT(IF(`Month` = 1 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Enero`,
	COUNT(IF(`Month` = 2 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Febrero`,
	COUNT(IF(`Month` = 3 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Marzo`,
	COUNT(IF(`Month` = 4 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Abril`,
	COUNT(IF(`Month` = 5 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Mayo`,
	COUNT(IF(`Month` = 6 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Junio`,
	COUNT(IF(`Month` = 7 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Julio`,
	COUNT(IF(`Month` = 8 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Agosto`,
	COUNT(IF(`Month` = 9 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Septiembre`,
	COUNT(IF(`Month` = 10 AND `Year` = 2025, `aux`.`Id_Booking`, NULL)) AS ` Octubre`
FROM `t_package` `aux_pk`
LEFT JOIN
(
    SELECT  `b`.`Id_Booking`,
            `bt`.`Id_BookingTour`,
            `bt`.`Id_Package`,
            `p`.`Package_Name`,
            COUNT(DISTINCT `btp`.`Id_Passenger`) AS `Passenger_Amount`,
            `b`.`Booking_DateConfirm`,
            YEAR(`b`.`Booking_DateConfirm`) AS `Year`,
            MONTH(`b`.`Booking_DateConfirm`) AS `Month`,
            DAY(`b`.`Booking_DateConfirm`) AS `Day`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 1, 0) AS `ReservaWeb`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 0, 1) AS `NotReservaWeb`,
            IF(`u`.`User_Type` = 2, 0, IF(`b`.`Booking_InPerson` = 1, `b`.`Booking_Type`, 8)) AS `Type`
    FROM `t_booking_tour` `bt`
    INNER JOIN `t_booking` `b` ON `b`.`Id_Booking` = `bt`.`Id_Booking`
    INNER JOIN `t_user` `u` ON `u`.`Id_User` = `b`.`Id_User`
    INNER JOIN `t_package` `p` ON `p`.`Id_Package` = `bt`.`Id_Package`
    INNER JOIN `t_passenger` `ps` ON `ps`.`Id_Booking` = `b`.`Id_Booking`
    INNER JOIN `t_booking_tour_passenger` `btp` ON `btp`.`Id_Passenger` = `ps`.`Id_Passenger`
    WHERE `b`.`Booking_DateConfirm` BETWEEN '2021-01-01' AND '2025-10-23'
    AND   `b`.`Booking_Status` IN (2, 3)
    GROUP BY `b`.`Id_Booking`, `p`.`Id_Package`
    ORDER BY `b`.`Booking_DateConfirm`
) `aux` ON `aux_pk`.`Id_Package` = `aux`.`Id_Package`
GROUP BY `aux_pk`.`Id_Package`
ORDER BY `Amount` DESC, `aux_pk`.`Package_Name` ASC



SELECT SUM(`aux`.`Passenger_Amount`) AS `Amount`,
    `aux_pk`.`Tour_Name`,
  SUM(IF(`Month` = 1 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` May`,
	SUM(IF(`Month` = 6 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS ` Dic`,
  SUM(IF(`Month` = 1 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` May`,
	SUM(IF(`Month` = 6 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS ` Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` May`,
	SUM(IF(`Month` = 6 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS ` Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` May`,
	SUM(IF(`Month` = 6 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS ` Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` May`,
	SUM(IF(`Month` = 6 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS ` Oct`
FROM `t_tour` `aux_pk`
LEFT JOIN
(
    SELECT  `b`.`Id_Booking`,
            `bt`.`Id_BookingTour`,
            `bt`.`Id_Package`,
            `p`.`Package_Name`,
            `t`.`Id_Tour`,
            `t`.`Tour_Name`,
            COUNT(DISTINCT `btp`.`Id_BookingTourPassenger`) AS `Passenger_Amount`,
            SUM(`btp`.`BookingTourPassenger_Price`) AS `Price`,
            `b`.`Booking_DateConfirm`,
            YEAR(`b`.`Booking_DateConfirm`) AS `Year`,
            MONTH(`b`.`Booking_DateConfirm`) AS `Month`,
            DAY(`b`.`Booking_DateConfirm`) AS `Day`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 1, 0) AS `ReservaWeb`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 0, 1) AS `NotReservaWeb`,
            IF(`u`.`User_Type` = 2, 0, IF(`b`.`Booking_InPerson` = 1, `b`.`Booking_Type`, 8)) AS `Type`
    FROM `t_booking_tour` `bt`
    INNER JOIN `t_booking` `b` ON `b`.`Id_Booking` = `bt`.`Id_Booking`
    INNER JOIN `t_user` `u` ON `u`.`Id_User` = `b`.`Id_User`
    INNER JOIN `t_package` `p` ON `p`.`Id_Package` = `bt`.`Id_Package`
    INNER JOIN `t_tour` `t` ON `t`.`Id_Tour` = `bt`.`Id_Tour`
    INNER JOIN `t_passenger` `ps` ON `ps`.`Id_Booking` = `b`.`Id_Booking`
    INNER JOIN `t_booking_tour_passenger` `btp` ON `btp`.`Id_Passenger` = `ps`.`Id_Passenger`
    WHERE `b`.`Booking_DateConfirm` BETWEEN '2021-01-01 00:00:00' AND '2025-12-31  23:59:59'
    AND   `b`.`Booking_Status` IN (2, 3)
    GROUP BY `b`.`Id_Booking`, `p`.`Id_Package`
    ORDER BY `b`.`Booking_DateConfirm`
) `aux` ON `aux_pk`.`Id_Tour` = `aux`.`Id_Tour`
GROUP BY `aux_pk`.`Id_Tour`
ORDER BY `Amount` DESC, `aux_pk`.`Tour_Name` ASC





SELECT SUM(`aux`.`Passenger_Amount`) AS `Amount`,
    `aux_pk`.`UserCountry_Name`,
    SUM(IF(`Month` = 1 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2021, `aux`.`Passenger_Amount`, NULL)) AS `Dic`,
    SUM(IF(`Month` = 1 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2022, `aux`.`Passenger_Amount`, NULL)) AS `Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2023, `aux`.`Passenger_Amount`, NULL)) AS `Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Oct`,
	SUM(IF(`Month` = 11 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Nov`,
	SUM(IF(`Month` = 12 AND `Year` = 2024, `aux`.`Passenger_Amount`, NULL)) AS `Dic`,
	SUM(IF(`Month` = 1 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Ene`,
	SUM(IF(`Month` = 2 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Feb`,
	SUM(IF(`Month` = 3 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Mar`,
	SUM(IF(`Month` = 4 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Abr`,
	SUM(IF(`Month` = 5 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `May`,
	SUM(IF(`Month` = 6 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Jun`,
	SUM(IF(`Month` = 7 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Jul`,
	SUM(IF(`Month` = 8 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Ago`,
	SUM(IF(`Month` = 9 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Sep`,
	SUM(IF(`Month` = 10 AND `Year` = 2025, `aux`.`Passenger_Amount`, NULL)) AS `Oct`
FROM `t_user_country` `aux_pk`
LEFT JOIN
(
    SELECT  `b`.`Id_Booking`,
            `bt`.`Id_BookingTour`,
            `bt`.`Id_Package`,
            `p`.`Package_Name`,
            `ps`.`Id_UserCountry`,
            `t`.`Id_Tour`,
            `t`.`Tour_Name`,
            COUNT(DISTINCT `btp`.`Id_Passenger`) AS `Passenger_Amount`,
            SUM(`btp`.`BookingTourPassenger_Price`) AS `Price`,
            `b`.`Booking_DateConfirm`,
            YEAR(`b`.`Booking_DateConfirm`) AS `Year`,
            MONTH(`b`.`Booking_DateConfirm`) AS `Month`,
            DAY(`b`.`Booking_DateConfirm`) AS `Day`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 1, 0) AS `ReservaWeb`,
            IF(`u`.`User_Type` = 1 AND `b`.`Booking_Type` = 1, 0, 1) AS `NotReservaWeb`,
            IF(`u`.`User_Type` = 2, 0, IF(`b`.`Booking_InPerson` = 1, `b`.`Booking_Type`, 8)) AS `Type`
    FROM `t_booking_tour` `bt`
    INNER JOIN `t_booking` `b` ON `b`.`Id_Booking` = `bt`.`Id_Booking`
    INNER JOIN `t_user` `u` ON `u`.`Id_User` = `b`.`Id_User`
    INNER JOIN `t_package` `p` ON `p`.`Id_Package` = `bt`.`Id_Package`
    INNER JOIN `t_tour` `t` ON `t`.`Id_Tour` = `bt`.`Id_Tour`
    INNER JOIN `t_passenger` `ps` ON `ps`.`Id_Booking` = `b`.`Id_Booking`
    INNER JOIN `t_booking_tour_passenger` `btp` ON `btp`.`Id_Passenger` = `ps`.`Id_Passenger`
    WHERE `b`.`Booking_DateConfirm` BETWEEN '2021-01-01 00:00:00' AND '2025-12-31 23:59:59'
    AND   `b`.`Booking_Status` IN (2, 3)
    GROUP BY `ps`.`Id_UserCountry`, `b`.`Booking_DateConfirm`
    ORDER BY `b`.`Booking_DateConfirm`
) `aux` ON `aux_pk`.`Id_UserCountry` = `aux`.`Id_UserCountry`
GROUP BY `aux_pk`.`Id_UserCountry`
ORDER BY `Amount` DESC, `aux_pk`.`UserCountry_Name` ASC