Decimal for Query

I need to make a total as formula below keep keep decimal 3 places (means 0,###) both from table1 and Table2:

Total = Sub RM Cons * Sub RM Order Q’ty + Main RM Cons * Main RM Order Q’ty.

Thanks and best regards,

DucLe

I don’t think you can answer it. Which field types did you use for Sub RM Cons; Sub RM Order Q’ty; Main RM Cons; Main RM Order Q’ty? Are they tables that are related or are they not otherwise related? Do you use HSQLDB, Firebird or others?

And you can upload a sample of your DB here. To upload, edit your question.

Here you can read the base documentation.

Hello,

Just a note, don’t see any reason for decimal positions in quantity fields.

Here is the Query SQL statement needed:

SELECT "Main RM Items",
       CAST(("Main RM Cons"*"Main RM Order Qty") +("Sub RM Cons"*"Sub RM Order Qty") AS NUMERIC(10,3)) "Total"
FROM (SELECT *
      FROM "Table1"
        JOIN (SELECT * FROM "Table2") ON "Main RM Items" = "Sub RM Item")

Here is what results (using the data in your question):

Dear Rastlinger & Harald Berger,

Thanks for your advices! They are so useful!

@DucLe

If an answer has solved your problem, please click on the large check mark in the circle to the left of this answer. It then shows the other participants that the question has been answered correctly.