Subject | Re: Optimizing a subquery |
---|---|
Author | Ali Gökçen |
Post date | 2006-07-13T16:19:36Z |
Hi Mr. Kokok
--- In firebird-support@yahoogroups.com, "kokok_kokok"
<kokok_kokok@...> wrote:
only redkit shoots before his shadow.
you need to calculete sum of sales before customer rows.
write a SP:
create procedure salesrates ..
returns customer_id ..., sales ..., total_sales ...
...
select sum(sales) from customers into :total_sales;
for select customer_id,sales from customers into :customer_id,:sales
do suspend;
end
thats all, you can use it in any reporter as a table:
select * from mysalesrates()
Ali
FFM#208
--- In firebird-support@yahoogroups.com, "kokok_kokok"
<kokok_kokok@...> wrote:
>You can't do it with a single query,
> Yes, it is correct, I need to show the percentage of sales over the
> total of all customers.
>
> Sales field is the total for one customer.
>
> At the end, I want to show:
>
> Customer Id
> Customer Sales
> % of Customer Sales / Total Sales for all customers
>
> Thank you
>
only redkit shoots before his shadow.
you need to calculete sum of sales before customer rows.
write a SP:
create procedure salesrates ..
returns customer_id ..., sales ..., total_sales ...
...
select sum(sales) from customers into :total_sales;
for select customer_id,sales from customers into :customer_id,:sales
do suspend;
end
thats all, you can use it in any reporter as a table:
select * from mysalesrates()
Ali
FFM#208