Board index » delphi » Select Top 10

Select Top 10

I like to sum some values and just show the top 10 of the result

I tried something like this:

SELECT Max((SUM(VAL)
FROM SALES
WHERE JAHR = 1999 and VKGRP = '901'
GROUP BY  Kunnr))

but it doesn't work. I work with Interbase or/and Paradox.

How can I get my Query run?

Herbert

Sent via Deja.com http://www.deja.com/
Before you buy.

 

Re:Select Top 10


SELECT region, Sum(sales) AS SumOfsales
FROM Table1
GROUP BY region
ORDER BY Sum(sales) DESC;

I'm not sure what your table looks like, but here it is working with a
simple 2-column table I created with 2 fields:
"Region" and "Sales". Multiple records per region, sum each region and
give me them from biggest to smallest sales total.
Note that "DESC" means descending. I.e., from biggest sales value to
smallest.
That's with a MS Access table, but it's probably similar, if not
identical, for Paradox.

Hope that helps (I hope I understood the question).

Liam Scanlan

Quote
Herbert Schlup wrote:
> I like to sum some values and just show the top 10 of the result

> I tried something like this:

> SELECT Max((SUM(VAL)
> FROM SALES
> WHERE JAHR = 1999 and VKGRP = '901'
> GROUP BY  Kunnr))

> but it doesn't work. I work with Interbase or/and Paradox.

> How can I get my Query run?

> Herbert

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Other Threads