Last value in two levels of group by in MySQL
SELECT DISTINCT
    CONCAT(YEAR(`date`),'/',WEEK(`date`)) as `week`,
    fruit,
    FIRST_VALUE(init) OVER (PARTITION BY fruit,`week` 
                            ORDER BY `date` ASC) AS 'first',
    FIRST_VALUE(end) OVER (PARTITION BY fruit,`week` 
                           ORDER BY `date` DESC) AS 'last'
FROM fruits_flow