Good day. There is a task "During the last week, how many clicks did the active traveler hotels?"
A request has been made for it.
SELECT SUM(qaapplicant.hotel_clickout_lastweek.clickout) FROM qaapplicant.hotel_clickout_lastweek JOIN qaapplicant.partner_hotel ON qaapplicant.partner_hotel.hotel_id = qaapplicant.hotel_clickout_lastweek.hotel_id JOIN qaapplicant.hotel ON qaapplicant.hotel.hotel_id = qaapplicant.hotel_clickout_lastweek.hotel_id WHERE partner_id = "p002" AND status = 1; The problem is that now I consider the entire amount of qaapplicant.hotel_clickout_lastweek.clickout , and it is required to read only the MAX values ​​for qaapplicant.hotel_clickout_lastweek.clickout . I hotel_clickout_lastweek there are 2 columns in the hotel_clickout_lastweek nameplate ( hotel_id and clickout ) and for one hotel_id can be different clickout and I need to take the maximum one.