Quantcast
Channel: Pentaho Community Forums
Viewing all articles
Browse latest Browse all 16689

Aggregating calculated fields

$
0
0
I am having a problem where if I apply a(n exact) formula to a field the metadata SQL generator will not apply the chosen aggregate.

In one of my table "[REPAIRS]" in my database I have a field "[REPAIR_PRICE]" which is stored as the actual repair repair price multiplied by 100 (so 25 is stored as 2500). So in my model I've got a field with the name "Repair Price" and the exact formula "REPAIRS.REPAIR_PRICE/100". If I select this "Repair Price" column in the metadata qUERY bUILDER I get this SQL -

Code:

SELECT
    REPAIRS.REPAIR_PRICE/100 AS COL0
FROM
    REPAIRS REPAIRS

Which works as expected. However if I try to apply an aggregation to the column I get this SQL -

Code:

SELECT
    REPAIRS.REPAIR_PRICE/100 AS COL0
FROM
    REPAIRS REPAIRS

When I would have expected -

Code:

SELECT
    SUM(REPAIRS.REPAIR_PRICE/100) AS COL0
FROM
    REPAIRS REPAIRS

The same SQL each time.

If I change the formula to "REPAIR_PRICE/100" and disable exact I get this SQL -

Code:

SELECT
    SUM(REPAIRS."REPAIR_PRICE/100") AS COL0
FROM
    REPAIRS REPAIRS

Which is correct except for the quotation marks.

Does anyone have any way around this issue? The DB server is MSSQL and I'm using the JNDI driver.

Viewing all articles
Browse latest Browse all 16689

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>