You are viewing this site as a guest. You can still ask questions and help others! Join our Dev2Dev IT Community to receive your own blog, share your knowledge, and much more.

Sum of colum by colum

1 reply [Last post]
Guest's picture
Guest

I have a table of orders by day. I have a query that return the total order amount by year and I want to also return the max order by month without having to add month as a field. So if total order in one year was $1M for a certain customer and lets suppose march was the higher order month with $200K I want it to return to $200K as following:

Cust TOTAL HIGHEST
WALMART $1M $200K

I dont want to have to break down everything by month to get the highest month. Any suggestions?

Lepa's picture
User offline. Last seen 2 years 20 weeks ago. Offline
Joined: 06/23/2008
Posts: 591
Re: Sum of colum by colum

Select CUST, TOTAL, Max(highest)
from your-table
group by CUST, TOTAL, YEAR

Doesn't this work?!

Give back to the community and help it grow!
* Help with unanswered forum questions and issues
* Register or login to share your knowledge at your own blog