johnkreagan
Posts: 2
|
| Posted: 02/25/2010, 1:04 PM |
|
Hi,
I need some advice on how to approach this issue I am running into.
I have a custom SQL statement that JOINS a few tables, totals "orders", and calculates a price for those orders, but now I need to add two labels giving me the total price and total count of "orders". Basically, I need to SUM two columns from my dataset whether or not the screen paginates.
Looking through examples, I got far enough to total the price and count per page, but not for the whole dataset.
I have the following custom code in the before show row event of my table.
$Order_List->Label1->SetValue($Order_List->Price->GetValue() + $Order_List->Label1->GetValue() );
Im starting to think that I am making this more complicated than it needs to be, but any help/advice would be very much appreciated.
|
 |
 |
tallmik
Posts: 23
|
| Posted: 02/25/2010, 3:50 PM |
|
What if you create a "before show" event for the page that this stuff is on.
In this event, execute a select statement where you sum the columns you want. Assign these to some labels on the page, and you will get the totals for the whole set, not just the rows on that page.
The downside is that you will be making a semi-expensive query on every page view.
Caching might help, as would de-normalizing your database, to include the totals in the base row for the screen...
e.g. you are showing songs in a library... each album (a table) has many songs (in a separate table...) denormalize to include the total of time of all songs for the album in the row in the database for the album (album id 23423, name=this, artist=that, total minutes = 107 mins). This would mean you have to do an update to both tables on each update to the song table... "ya gots to make yer choices".
Michael
|
 |
 |
|