This project has moved and is read-only. For the latest updates, please go here.

Calculated column

Dec 4, 2013 at 10:58 PM
Edited Dec 4, 2013 at 11:05 PM
how can i perform the following query over esent db?... this seems to be very hard to do !

a table with x, and y columns

SELECT * , (10 * ACOS( @x ) * COS( x) * COS( y) – SIN( RADIANS( @y ) ) ) AS mycol
FROM mytable
Dec 10, 2013 at 11:43 PM
I confess that my SQL knowledge is very weak.
Is this for a one-off query or a regular query?
If it's a one-off, then you can create a temp database to do the sorting.

If it's a regular query, then you can look in to 'Callback columns', and create a secondary index over this calculated column. This means you have another index to maintain, which can get expensive if you create too many indices. Look at ColumndefGrbit.ColumnUserDefinedDefault.
        /// <summary>
        /// The default value for a column will be provided by a callback function. A column that
        /// has a user-defined default must be a tagged column. Specifying JET_bitColumnUserDefinedDefault
        /// means that pvDefault must point to a JET_USERDEFINEDDEFAULT structure, and cbDefault must be
        /// set to sizeof( JET_USERDEFINEDDEFAULT ).
        /// </summary>
        ColumnUserDefinedDefault = 0x8000,