Questions tagged [calculated-columns]

A calculated column is calculated from an expression that can use other columns in the same table

A calculated column is calculated from an expression that can use other columns in the same table. The expression can be a noncomputed column name, constant, function, and any combination of these connected by one or more operators. The expression cannot be a subquery.

2235 questions
4
votes
1 answer

add column to data frame, testing categorical variable in other column

I have referred: How to add a factor column to dataframe based on a conditional statement from another column?, How to add column into a dataframe based on condition in R programming and R: Add column with condition-check on three columns? .…
vagabond
  • 3,526
  • 5
  • 43
  • 76
4
votes
1 answer

Add a column to dataframe in R, based on greater than or less than condition in previous columns

A very basic question. I have a data frame with 14 variables and 576 observations. > head(Boston) crim zn indus chas nox rm age dis rad tax ptratio black lstat medv 1 0.00632 18 2.31 0 0.538 6.575 65.2 4.0900 1 296 15.3…
vagabond
  • 3,526
  • 5
  • 43
  • 76
4
votes
2 answers

use function from another database in computed column

I have a set of custom CLR functions installed in single database. When I need to use these functions in queries/views/procedures on another database, I simply reference them by three-part name [db].[schema].[function]() and it works fine. But I…
4
votes
3 answers

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…
Alan M.
  • 1,309
  • 2
  • 19
  • 29
4
votes
1 answer

Create non-NULL computed column for constant CHAR(1) in SSMS

In my database I have some computed columns to help ensure referential integrity constraints. I use computed columns and not default-value columns because LINQ2SQL, which is what I use, does not understand default values from the database. My…
user166390
4
votes
3 answers

Include an additional counter in the MySQL result set

Can I include an additional counter in a MySQL result set? I have the following query which gives me two columns back. I need an additional column (only in the result) indicating the row of each line in the result set. select orderid,…
Uwe Ziegenhagen
  • 683
  • 2
  • 20
  • 35
4
votes
4 answers

SharePoint: Calculated Column Values Disappear When Editing List Item. Any ideas?

I have a calculated column in a custom SharePoint 2007 list, with the following formula: =CONCATENATE("IR-",[ID],"-",LEFT(UPPER([Title]),25)) If an item is created in the list, everything is fine, however, when an item is updated the [ID] column is…
program247365
  • 3,951
  • 7
  • 33
  • 44
3
votes
1 answer

How to convert EF properties into SQL Server's computed columns?

I'd like to transform these Entity Framework's properties into SQL Server's computed columns. Is it possible? All other properties specified are table fields. Moreover, considering that I am using Code First, how I should specify the computed…
Larry
  • 573
  • 5
  • 14
  • 31
3
votes
1 answer

How to make a computed column nullable in SQL Server

I use SQL Server 2008 and Entity framework 4.1 database first approach . Is there any way I could create null-able Computed column ? I can't create like this : Alter Table Employee Add FullName nullable as LastName + ' ' +FirstName If the answer…
Mostafa
  • 3,002
  • 10
  • 52
  • 79
3
votes
1 answer

If I make an SQL View with computed columns, but select a subset of those columns, what performance hit am I likely to take

If I have a view in SQL which contains various computed columns, some of which could be very expensive, but only select a few columns out at any one time will I be taking any more of a performance hit, than if I was to separate the views out to…
Matt Fellows
  • 6,512
  • 4
  • 35
  • 57
3
votes
1 answer

Sharepoint Date Time Calculated Column

I have 2 columns sDate ( Start Date ), eDate ( End Date ) in my list. The functionality I need if(eDate == "" ) print sDate // Nov 10 else if(MONTH(sDate) == MONTH(eDate)) print sDate("mmm dd") + eDate(" - dd") // Nov 10 - 17 else print…
Vabs
  • 485
  • 1
  • 5
  • 17
3
votes
3 answers

Compute m columns from 2m columns without a for loop

I have a dataframe where some columns are name-paired (for each column ending with _x there is a corresponding column ending with _y) and others are not. For example: import pandas as pd import numpy as np colnames = [ 'foo', 'bar', 'baz', …
DeltaIV
  • 4,773
  • 12
  • 39
  • 86
3
votes
1 answer

How to create custom sequences in PostgreSQL?

I would like to know how I can do something equivalent to what I did with the "code" column of the following table in SQL Server and implement it in PostgreSQL. CREATE TABLE test( id INT IDENTITY(1,1) NOT NULL, code AS ('P' + RIGHT('0000' +…
3
votes
0 answers

index on persisted computed column slower than index on non-persisted computed column

we have a big table with a varchar(max) column containing elements that are 'inspected' with charindex. For instance: select x from y where charindex('string',[varchar_max_field]) > 0 In order to speed that up, I created a computed column with the…
WillemG
  • 31
  • 2
3
votes
1 answer

Every New Value in a Column to Automatically Multiply by X

In a spreadsheet, I am trying to somehow make it so any new numerical value that gets inputted into a cell in column D to multiply by 85%. Basically, if I go to any cell 2-100,000 in column D and input a numerical value, I want it to automatically…
danklok
  • 33
  • 2