I can not programmed, the result must be ORDER BY numbers and years. Every year the numbers go over again, first we need to be shown the current year with the numbers aligned. Below comes the previous year with arranged numbers and so on.
Any idea
Thank you
SELECT k.ID, k.name, k.lastname, k.number, YEAR(k.year),
(k.prices + IFNULL(z.prices, 0) ) as cijena, ( (k.prices + IFNULL(z.prices, 0)) - IFNULL(u.prices, 0) ) as dug, IFNULL(z.prices, 0) as iznos from
( select ID, name, lastname, prices, year, number, from user group by ID) as u
left join (select sum(prices) as prices, ID1 from uplate group by ID1) as u
on u.ID1 = k.ID
left join (select sum(prices) as prices, IDk from zaduzenje group by IDk) as z
on z.IDk = k.ID
GROUP BY k.ID