Skip to content

Latest commit

 

History

History
45 lines (35 loc) · 1.3 KB

README.md

File metadata and controls

45 lines (35 loc) · 1.3 KB

Задание

image

image

Запуск

git clone https://github.com/EgorZhizhlo/MillionAgentsTask.git
cd MillionAgentsTask
docker build -t converter .
docker run -d -p 8000:8000/tcp converter

Сайт будет доступен по адрессу http://localhost:8000

image

Решение

SELECT 
    user_id,
    SUM(CASE WHEN EXTRACT(YEAR FROM created_at) = 2022 THEN reward ELSE 0 END) AS reward_sum_2022
FROM 
    reports
GROUP BY 
    user_id
HAVING 
    MIN(EXTRACT(YEAR FROM created_at)) = 2021;

image

Решение:

SELECT 
    r.barcode,
    r.price
FROM 
    reports r
JOIN 
    pos p ON r.pos_id = p.id
GROUP BY 
    r.barcode, r.price
HAVING 
    COUNT(DISTINCT p.title) > 1;