[quote=“avvy651, post:9, topic:85877”]
I read somewhere that when joining queries ? the fieldnames had to be the same[/quote]
If fieldnames are the same you could join two queries in MySQL with
… FROM "EONElectric" JOIN "EONGas" USING( "ID1")
But this doesn’t work with internal HSQLDB. So: Field names must be named different in one table. If you are using different tables and same field names in different tables - how should the database knew which field should be chosen?
No, “EONElectric”.“ID1” is a combination of tablename and field name. But in every calculated field the table names are missing. So Base has to decide which field it want to use. Base decides this by this entry:
… FROM "EONElectric", "EONGas" …
If there is no table name first try to find it in “EONElectric”. If it isn’t there try “EONGas”.
Now have a look to a part of the code of your query:
… "EONGas"."EPG",
( "Gas Cost" ) - ( "EPG" ) AS "Cost After EPG",
( "No Days" ) * ( "Standing Charge" ) / 100 AS "Total Standing Charge" …
All fields, which appear directly without calculation have got a table name like "EONGas"."EPG"
. All fields in a calculation won’t have a table name. So Base takes the first table in the code, if there are fields with the same name in both tables.
Base takes ( "Gas Cost" ) - ( "EONElectric"."EPG" )
, but you don’t want it. You need ( "Gas Cost" ) - ( "EONGas"."EPG" )
instead.
Base takes ( "EONElectric"."No Days" ) * ( "EONElectric"."Standing Charge" )
, but you don’t want it. You need ( "EONGas"."No Days" ) * ( "EONGas"."Standing Charge" )
instead.
And if all this has been corrected it calculates what you want, but the field names are the same for many fields. So you wont know which “EPG”, “Cost after EPG” … is shown. You could only decide it by the position of the field in the query. So the better way would be to write an alias like …"EPG" AS "EPG_Gas"…