Распределение заявок по годам SELECT YEAR DATA AS Год COUNT LES AS Кол

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
//1. Распределение заявок по годам:
SELECT YEAR(DATA) AS 'Год', COUNT(LES) AS 'Количество заявок' FROM BASE1.BRAK GROUP BY YEAR(DATA) ORDER BY YEAR(DATA) ASC;
//2. Распределение брака по годам:
SELECT YEAR(DATA) AS 'Год', COUNT(LES) AS 'Количество брака' FROM BASE1.BRAK WHERE PRICH=1 GROUP BY YEAR(DATA) ORDER BY YEAR(DATA) ASC;
//3. Распределение фальсификации по годам:
SELECT YEAR(DATA) AS 'Год', COUNT(LES) AS 'Количество фальсификаций' FROM BASE1.BRAK WHERE PRICH=2 GROUP BY YEAR(DATA) ORDER BY YEAR(DATA) ASC;
//4. Распределение брака по изготовителям:
SELECT IZG AS 'Изготовитель', COUNT(LES) AS 'Количество брака' FROM BASE1.BRAK WHERE PRICH=1 GROUP BY IZG ORDER BY COUNT(LES) DESC;
//5. Распределение брака по годам и по странам:
SELECT (SELECT name FROM lands WHERE id=LAND) AS 'Страна', YEAR(DATA) AS 'Год', COUNT(LES) AS 'Количество брака' FROM BRAK WHERE PRICH=1 GROUP BY LAND, YEAR(DATA) ORDER BY (SELECT name FROM lands WHERE id=LAND) ASC;