Ask Your Question

Computed field in query (on Firebird in Libreoffice)

asked 2019-03-06 14:36:59 +0200

taifatul gravatar image

updated 2019-03-06 14:50:18 +0200

ebot gravatar image

edit-ebot: unnecessary call for help removed. Shouting shut off.

How to use a computed field in a query ? C:\fakepath\2019-03-06_161326.pngimage description

edit retag flag offensive close merge delete


image description

is the calculated field not available later in other calculated fields?

taifatul gravatar imagetaifatul ( 2019-03-06 19:04:39 +0200 )edit

Doesn't that need to be CAST(("БО_2_КАТ" * 0.25) AS DECIMAL(5,2)) AS "Bo+0,25" (note last AS before column alias)?

And specifically in this case, I don't see a value of using calculated field in the "dffgd" calculation over simple CAST(("БО_2_КАТ" * 1.25) AS DECIMAL(5,2)).

Mike Kaganski gravatar imageMike Kaganski ( 2019-03-06 19:58:46 +0200 )edit

2 Answers

Sort by » oldest newest most voted

answered 2019-03-06 18:02:07 +0200

Ratslinger gravatar image

updated 2019-03-06 19:45:21 +0200


This is a bug when using Firebird. The problem is the result does not have the decimal inserted. This can be corrected by 'casting' the computed result. For this you will need to use the SQL view of the query.

See my answer in this post -> Base - Calculating Times

Edit 2019-03-06:

No you cannot use a calculated field until it has been "Select"ed. You can do what you want in multiple ways. Here are two.

Calculate the percentage and join to main select on the record ID:

image description

You can also perform without a "Join" by doing the calculation twice:

image description

This of course depends upon if you need both the percentage and the percentage plus original amount. If you just need a total then:

Select ID,  Cast(("AMT1" *.25) + "AMT1"  As DECIMAL(5,2)) As "Total" FROM "CalcTest"

will work also.

edit flag offensive delete link more


and then again the calculated field is unavailable ?

taifatul gravatar imagetaifatul ( 2019-03-06 18:57:43 +0200 )edit

is the calculated field not available later in other calculated fields?

taifatul gravatar imagetaifatul ( 2019-03-06 19:05:10 +0200 )edit

Ratslinger , Mike Kaganski

thank !!! you helped me a lot

taifatul gravatar imagetaifatul ( 2019-03-14 20:09:17 +0200 )edit

I implemented it through creating multiple queries query based on another query, a computed field is also available

taifatul gravatar imagetaifatul ( 2019-03-14 20:12:37 +0200 )edit

and in the future, the developers will not add this feature in the requests ?

taifatul gravatar imagetaifatul ( 2019-03-14 20:21:30 +0200 )edit

@taifatul SQL is concerning the database and not LO. For 'added features' in that respect you need to deal with the database maintenance group. Don't see this as a reasonable request though.

Ratslinger gravatar imageRatslinger ( 2019-03-14 21:16:49 +0200 )edit

answered 2019-03-06 19:15:27 +0200

taifatul gravatar image

image description

edit flag offensive delete link more



Please use original question for further information. Answers should be used for answering original question only.

Ratslinger gravatar imageRatslinger ( 2019-03-06 19:38:25 +0200 )edit

By the way, the way you calculate your Bo+0,25 in the question's screenshots doesn't look like "salary + 25%". It looks more like simple 25% of something (but name "БО_2_КАТ" looks like it's base salary (базовый оклад)?) Anyway: if your "total" needs to be salary + salary*0.25, then it's simple salary * 1.25.

Mike Kaganski gravatar imageMike Kaganski ( 2019-03-06 20:06:59 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower


Asked: 2019-03-06 14:36:59 +0200

Seen: 207 times

Last updated: Mar 06 '19