0
I’m using sqlite, and I have a table like:
year | clients
---- | -------
2000 | 1
2000 | 2
1999 | 3
1999 | 5
2000 | 4
1999 | 6
This is just one example. I want to find the year when the total of customers was higher.
The best I could do was to separate for each year, add up the clients, and present each year with the respective sum. But I don’t know how to present only the year it was greatest.
I want to present the year and total customers. That is to say:
1999 | 14
I used:
select year, sum(clients) from table group by year;
I’ve tried too
select year, max(sum(clients)) from table group by year;
This is [en.so], the questions and answers here need to be on portuguese. You can [Dit] your question and translate it.
– Jéf Bueno
It’s already translated. Thanks for formatting the text, I’m a turnip in this xD
– Alcachofra
You can use the LIMIT clause:
select year, sum(clients) from table group by year order by sum(clients) DESC limit 1;
– anonimo
Quiet. There is a formatting guide that you can always use.
– Jéf Bueno