Home End User

Problem with Sorting by Calculated Fields.

edited April 2009 in End User
Hi

Report Builder 11.03Ent, Delphi 2007

I am demonstrating the problem with the Orders table in DBDemos

I want to add up the AmountPaid by CustNo and sort by the sum(AmountPaid).
The sql would be as follows:

SELECT orders.CustNo, SUM(orders.AmountPaid) SUM_orders_AmountPaid
FROM "orders.db" orders
GROUP BY orders.CustNo
ORDER BY 2

The problem I am having is correctly selecting the SUM_orders_AmountPaid
field from the Sort options in the dataview. If you select the
SUM_orders_AmountPaid field as one of the sort options it puts AmountPaid
in the list of sort fields and not SUM_orders_AmountPaid. The resulting
sql and data is incorrect.

I have found a solution but it is convuluted and obviously wrong but is as
follows:

1. Select SUM_orders_AmountPaid as Sort field [SUM_orders_AmountPaid
goes from Available and AmountPaid appears in Sort Fields]
2. Unselect AmountPaid from Sort fields [AmountPaid goes from Sort Fields
but now appears twice at the bottom of Available fields]
3. Select both of the available AmountPaid fields. [You will now have
AmountPaid and Sum_orders_AmountPaid in Sort Fields]
4. Unselect AmountPaid from the SortFields [You will now be left with
Sum_orders_AmountPaid ]

Everything is now correct!


Regards

Tim Murfitt

Comments

This discussion has been closed.