Mike
Thanks for that suggestion.  I'm out of the office today but will examine it to see what makes it tick tomorrow, and see if I can use something along those lines.
Appreciate your help.
Mark
----- Original Message -----
Sent: Wednesday, September 26, 2001 6:58 PM
Subject: Re: [DUG]: Paradox SQL - Group totals as % of Grand total

Mark
The following works in Database Desktop (v7.0) - haven't verified how it goes in Delphi.
 
Table has Amount and ExpType (among other things) in an Expenses table. The following SQL provides total expenses by type and as percentage of total and has a grand total at the end.
 
select "zzzzzz", sum(amount), 100 from expenses e3
union
select exptype, sum(amount), (sum(amount)/(select sum(amount) from expenses e2) * 100)  from expenses e1
group by exptype
 
The "zzzzzz" (in my query) managed to put that line (grand total) at the end - it could be a column you don't show in the report.
The 100 in first select sets up the column - and ensures percentages add up to 100 at the end <g>.
 
HTH
Mike
----- Original Message -----
Sent: Wednesday, September 26, 2001 11:47 AM
Subject: [DUG]: Paradox SQL - Group totals as % of Grand total

Hi
 
Using SQL I want to assemble a dataset (to be used by a Quick Report) that will allow me to express each group total as a percentage of the grand total. 
 
I can't calculate the percentage at the group level in the report because we don't have the total until the end, so it seems that I need to have the grand total read into the dataset.
 
Are there any tricky ways of achieving this? or is there no alternative to just doing a double pass through the dataset?
 
TIA
 
Mark

Reply via email to