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.

  • Of the task is not clear anything. it’s clear from the English text that one needs to find out how many clicks the “collective travelers” have made in all the “active hotels” over the last week. But how to get exactly the "collective" and how they differ from the "non-collective", as well as the difference between "active" hotel and "not active" is not clear. And it is not clear why you needed a certain maximum, based on the text of the task, there is no talk of any maximum there. Apparently you need to get only the last week in where, define "collective" and "active" and then make a group by and sum - Mike
  • Sorry for the incomplete information on the task. The issue has already been resolved. - user272177

0