SQLite Forum

Help needed to return the right math results in sql query
Login
> it won't do any good ...

Here is your last posted SQL in this thread, annotated:<code>
select -- This is the "outer SELECT" here.
   EG, -- Creates a tuple element named EG as projected from this outer SELECT. [a]
       -- It uses well-defined projected tuple element EG from the inner SELECT.
   GPVBW/1000000-EG as Diff, -- Creates <i>ditto</i> named  Diff as <i>ditto</i>
       -- It uses ... elements named EG and GPVBW from inner Select (or fails)
   Delay -- Creates a tuple element named Delay as projected from this outer SELECT
       -- It uses ... element named Delay from inner Select (or fails)
 -- None of the above names used in expressions (or lone terms) binds to any of
 -- the tuple elements projected from this outer SELECT. They can only bind to
 -- named tuple elements projected from the below inner SELECT.
from (
   select -- This is the "inner SELECT" here.
      \*, -- Presumably, this creates GPVBW and Delay as projected tuple elements.
      TID\*0.003\*250 as EG, -- Creates EG projected from this inner SELECT
      Diff/0.003/250/750\*60 -- Creates a projected tuple element with a poorly 
                            -- defined name which is hard to use and useless here.
   from CalculateGrowth 
)
</code>

This is very fundamental to using SELECT, so I encourage you to study and understand the name scoping (or possible binding) rules in effect as noted above.

----

\[a. This is per convention; SQL language definition does not require it. \]