calculated-columns

Calculated field in RoR (act as an ActiveRecord method)

I am building an app for cognitive tests in Rails. I have a number of tests (Quiz objects) for my visitors. In the home page I want to show only quizzes that are ready for consumption: they must have a number of questions and a number of possible answers. Of course I could query with SQL, or create a class method retrying all objects whe...

Flex: Add TOTAL column for AdvancedDataGridColumnGroup?

I have an AdvancedDataGrid that has a couple AdvancedDataGridColumnGroup's I would like each group to have an extra column, that shows the total of all the other columns in the group. I also need to use my own calc function to calculate the totals. Is there anyway to do this? I hope I explained this well. Thanks!! ...

Impact on NHibernate caching for searches with results including calculated value mapped as a formula (e.g. rank)

When defining a calculated property using a formula in NHibernate, what are the implications for when the formula varies its result depending on the query restrictions, especially with regards to query caching? More specifically, consider the following simple C# class: public class Entity { public Entity() { } public virtual in...

looks like circular refference but didnot work

I have 3 columns. Income(column E), expenses(column F) and remainder(column G). Income(column E) - to use this column to input income value; Expense(column F) - to use this column to input expense value; I want to calculate G column only each time I enter income and expenses with such formula(example): G2=G2+E2-F2 ...

SQL Server and Calculated Fields?

So I'm creating an app that with users who can earn "points" in many different ways. Some of these point accruals occur because of their profile, actions they've taken, etc. (i.e. spread across multiple tables). I don't want to manually add points in a field when certain actions occur because I want to ensure number consistency. I would...

Wrong Result after Refresh pressed on DbNavigator Delphi

I have faced a very strange situation here. I am accessing database (MDB) through JET. I use DBGrid and DBNavigator to allow user access it. Dataset is created using TADOQuery component, with the following query: SELECT *, (DateDiff ('y',[Birth Date], Now())) AS [Age] FROM TableName It works fine. But whenever I press Refresh button ...

Modify (jQuery) JS to include code to track changes done on Checkbox and Dropdown list and update price

Hi all, I have a code in javascript and I am using jQuery Calculation plugin (can be downloaded from link text). The form that I have is kind of like shopping cart form i.e. the prices update according to the quantity entered. The form has text boxes which accepts numbers and this denotes the quantity. Once this quantity is entered/modif...

MySQL View: How do I set default value of a calculated field to 0?

I use the following statement to create a percentage calculation in a view: round(((Surveys.RejectedAsAdvertising / Surveys.Responses) * 100),0) AS PercentageAdvertising Basically, I divide the number of responses to a certain question (in this case, is something considered to be advertising) by the total number of responses. In the e...

MySQL Views: Referencing one calculated field (by name) in another calculated field

How can I define a view that has two calculated fields, for instance... ('TableName'.'BlueSquares' + 'TableName'.'RedSquares') AS TotalSquares, ('TableName'.'BlueCirles' + 'TableName'.'RedCircles') AS TotalCircles ... and create a third calculated field that's based on the first two calculated fields, as in... ('ViewName'.'TotalSqu...

How do I strip spaces out of data in a SharePoint column?

I have a MOSS 2007 list with a column which contains hundreds of business and city names. These names are text commonly with multiple words, such as "City of Austin". I have setup filtering and data view web parts to allow a page to display contents of the list based on a query string. All works well, except that I need to generate th...

Monitoring a calculated data (A person's age) in SQL Server

I have a table, tblClient, which stored a client's date of birth in a field of type datetime, DOB. The goal here is that, when a client reaches 65 years old (need to be calculated thru DOB), I need to insert a new record into another table. But since the age of a client does not change due to a database transaction (INSERT,UPDATE,DELET...

PostgreSQL Views: Referencing one calculated field in another calculated field

I have the same question as #1895500, but with PostgreSQL not MySQL. How can I define a view that has a calculated field, for example: (mytable.col1 * 2) AS times_two ... and create another calculated field that's based on the first one: (times_two * 2) AS times_four ...? ...

How to use a calculated column in where condition?

Please tell me how to use a calculated column in where condition in oracle 9i? I want to use something like select decode (:pValue,1, select sysdate from dual, select activation_date from account where AcNo = 1234) as calDate where caldate between startDate and endDate; ...

Sharepoint 2007 calculated Date field shows incorrectly in non-US region

If a SharePoint user (with Regional Settings set to UK) views a calculated date field in a View details form, the field shows incorrectly. I am using: ddwrt:FormatDateTime(string(@RenewalDate), 1033, 'dd MMMM yyyy') Which shows 04 January 2010 for 01/04/2010 and, doesnt show unresolvable dates such as 31-Dec-2010. This applies even ...

sharepoint: conditional formula for calculated field

hi all, i want to create a formula for change my value from EUR into USD. FIELD1 (choice): EUR, USD FIELD2 (number): amount in EUR or USD Now, if USD is selected in FIELD1 following should happen: calaculate FIELD2*0,71 otherwiese the result is FIELD2. FIELD3 (calculated): =IF(FIELD1="USD", (FIELD2*0,71), FIELD2)) When I use thi...

Calculation error in Datasheet view in SharePoint

I have a custom list, with calculation, in SharePoint. Everything worked fine until recently when the DataSheet will show strange or wrong % calculation in a % column. But the Standard View will show correct values. IT checked the server side and everything looked ok, I checked the formulas and even re-did them in the column and the issu...

Top 10 collection completion - a monster in-query formula in MySQL?

I've got the following tables: User Basic Data (unique) [userid] [name] [etc] User Collection (one to one) [userid] [game] User Recorded Plays (many to many) [userid] [game] [scenario] [etc] Game Basic Data (unique) [game] [total_scenarios] I would like to output a table that shows the collection play completion percentage fo...

calculated column or stored procedure or just php function needed ?

I have an order table in MySQL database, having a field/column which stores the date timestamp of when the order was placed. I need to calculate when the order must be shipped. I could probably figure out how to write a function to calculate the ship date and call that when ever needed but I think, not sure it may make more sense to ha...

Am getting un-expected NULL values in a Datagridview's calculated column

I have a Bindingsource that am setting as a datasource to a DataGridView control. In its dataset query i have a calculated column(Column1). When i go to the Bindingsource's tasks and click Preview Data i can, for my Column1 other rows have data values returned and for other rows NULL is returned which is ok and expected. The problem is ...

T-SQL Operations on a Calculated Date Field

Can I do WHERE operations on a calculated date field? I have a lookup field, which has been written badly in SQL and unfortunately I can't change it. But basically it stores dates as characters such as "July-2010" or "June-2009" (along with other non date data). I want to extract the dates first (which I did using a LIKE opertor) and th...