Optimizing my query using MAX

L

Lina

I need some one to help me Optimize my query using MAX or DMax or Top 1,
however.

I have a large result query that sumirized the sales (for each region) from
past months. Then I need to find the max data from last months for each year.
I have used Dmax, I have used a subquery in the select section, I have used a
Top 1 in the having section... all of them give me the same result which is
the correct one. My problem is the speed. It takes too long to be executed.

Is there a way I can work this out more efficiently?

Thanks a lot in advanced, Lina
 
M

MGFoster

Lina said:
I need some one to help me Optimize my query using MAX or DMax or Top 1,
however.

I have a large result query that sumirized the sales (for each region) from
past months. Then I need to find the max data from last months for each year.
I have used Dmax, I have used a subquery in the select section, I have used a
Top 1 in the having section... all of them give me the same result which is
the correct one. My problem is the speed. It takes too long to be executed.

Is there a way I can work this out more efficiently?

Thanks a lot in advanced, Lina

Using the MAX() function requires the query engine to create a new
temporary table (or file) of the sorted data and then go thru that data
searching for the data that matches the MAX criteria. Sometimes you can
increase the speed of queries on summary queries by temporarily storing
the summarized data in a temp. table, then run the MAX query against the
temp. table. YMMV.

You could also post your query (queries) and see if someone can come up
with a better solution(s).
 
Top