OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[SOLVED] Calculate with Alias / calculated Fields

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base
View previous topic :: View next topic  
Author Message
hwoehrle
General User
General User


Joined: 21 Sep 2009
Posts: 14
Location: Germany, Ulm

PostPosted: Thu Feb 18, 2010 2:52 am    Post subject: [SOLVED] Calculate with Alias / calculated Fields Reply with quote

Hi,

is there a way to use calculated fields in the same query for further calculation?

For example, i need to do some calculation on areas and process them further. My area-calculation looks like:
Code:

IFNULL(
CASEWHEN( "Massbezug" = 'a', ( ( "Breite_a" * "Laenge_a" ) + "Flaeche_a" ), (
  CASEWHEN( "Massbezug" = 'm', ( ( "Breite_m" * "Laenge_m" ) + "Flaeche_m" ), (
     CASEWHEN( "Massbezug" = 'i', ( ( "Breite_i" * "Laenge_i" ) + "Flaeche_i" ), 0 ) ) ) ) ) * "Anzahl_n"*"Faktor", "Anzahl_n"*"Faktor" ) AS "Flaeche_Schicht"

This area i need for six other calculated fields. Is there any elegant way other than repeate the area-calculation in each of them?

Best regards,
heiko


Last edited by hwoehrle on Mon May 17, 2010 11:31 pm; edited 1 time in total
Back to top
View user's profile Send private message
Sliderule
Super User
Super User


Joined: 29 May 2004
Posts: 2474
Location: 3rd Rock From The Sun

PostPosted: Thu Feb 18, 2010 8:36 am    Post subject: Reply with quote

If I am understanding your question and what you are trying to do correctly, if it were me ( famous last words ) . . . what I would do is create a View.

A View, in a database, is 'treated' just like a table, but, it contains no data. Rather, it tells the database what data to retrieve. In this case, you can define the calculation for "Flaeche_Schicht" once, if you include the Primary Key in the View. That is, your view would have two fields ( assuming your Primary Key is made up of one field ):
  1. The Primary Key Field(s)
  2. The calculation for "Flaeche_Schicht"
Now that you have 'one' calculation for "Flaeche_Schicht", whenever you wanted the "Flaeche_Schicht" again, for example in a Query, just include your original table, AND the View, linked by the Primary Key.

Note: To create a View , after opening your database, click on Tables on the left, and, Create View...

I hope this helps, please be sure to let me / us know.

Sliderule

Thanks to add [Solved] in your first post title ( edit button ) if your issue has been fixed / resolved.
Back to top
View user's profile Send private message
hwoehrle
General User
General User


Joined: 21 Sep 2009
Posts: 14
Location: Germany, Ulm

PostPosted: Mon May 17, 2010 11:32 pm    Post subject: Thanks! Reply with quote

Many thanks to sliderule for saving my day once again! Wink
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Base All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group