(:I r937, it works perfectly!! I followed your suggestions and first made a table 'client_year_totals' and cut part of your code like this:
select cliente
, total
, año
from TOTALES as CTE
where 3 >
( select count(*)
from TOTALES
where año = CTE.año...
Thanks PHV, my last attempt was....
SELECT A.cliente, A.total, A.año
FROM PEDIDOS
INNER JOIN (
SELECT cliente, sum(parcial) as total, year(fecha) as año
FROM PEDIDOS
GROUP BY año
ORDER BY año, total
LIMIT 3) AS A
what gives lots of...
Hello, can anybody help me with this? I have a 2500 records in one table where i have registered the last 5 years sales. How can I
>>sum all the sales of a customer in a given year
>>get the top 3 buyers in a given year
>>for the whole period (5 years)
>>in only one sql stament, if possible...
Hello, can anybody help me with this? I have a 2500 records in one table where i have registered the last 5 years sales. How can I
>>sum all the sales of a customer in a given year
>>get the top 3 buyers in a given year
>>for the whole period (5 years)
>>in only one sql stament, if possible...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.