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
5
votes
1 answer

Creating a derived field based on df value comparison in python pandas

I have 2 dataframes - one is a data source dataframe and another is reference dataframe. I want to create an additional column in df1 based on the comparison of those 2 dataframes df1 - data source No | Name 213344 | Apple 242342 | Orange 234234 |…
yuzu
  • 75
  • 6
5
votes
1 answer

Computed column with alias is not mapping into TypeORM Entity

I'm trying to get data from a table of a MySQL database using TypeORM in my Express.js project. I'm using QueryBuilder to get data. My implementation: const result = await this.repository.createQueryBuilder("post") …
Zunayed Shahriar
  • 2,557
  • 2
  • 12
  • 15
5
votes
3 answers

Calculate a column value during INSERT

I am using Postgresql 8.3 I have a Database table contaning buy_value and sell_value. I wish to add a DEFAULT function so that on Every Insert, database will calculate the profit according to the buy and sell values and insert that to the related…
Mp0int
  • 18,172
  • 15
  • 83
  • 114
5
votes
2 answers

PySpark Dataframe create new column based on function return value

I've a dataframe and I want to add a new column based on a value returned by a function. The parameters to this functions are four columns from the same dataframe. This one and this one are somewhat similar to what I want to but doesn't answer my…
Ali
  • 7,810
  • 12
  • 42
  • 65
5
votes
2 answers

when the computed column will update?

I have computed column in table called "Claim" and definition of column is calling one scalar function. I created a 10000 claims so when i select those 10000 claims the computed column will update are when 10000 rows inserting itself the computed…
VInayK
  • 1,501
  • 6
  • 34
  • 47
5
votes
1 answer

MySQL: When is a virtual generated column's value computed?

Let's say that I have a table t with 4 normal columns n1, n2, n3, n4 and 1 virtual computed column, c1. If I run the following query: select n1, n2 from t; , is the value of c1 computed for each row, even though I have not included it in the…
euphoria83
  • 14,768
  • 17
  • 63
  • 73
5
votes
1 answer

Splitting single data frame row into multiple rows while performing calculation

I have a df akin to df1 where I want to break out the rows so that the HOURS column is in intervals of 4, shown in df2. How would I approach this problem and what packages are recommended? IDs can have more than one sequence on a given day. For…
samuelt
  • 215
  • 1
  • 2
  • 10
5
votes
2 answers

New column in the start of a data table

I can add a new column to a data.table like this: DT = data.table(A=sample(3, 10, TRUE), B=sample(letters[1:3], 10, TRUE), C=sample(10)) DT[, new:=1:10] But is there a clever way to set it to the start of the data.table? - I know i can…
Jeppe Olsen
  • 968
  • 8
  • 19
5
votes
3 answers

Get Year of CreatedBy date in a calculated column

I am trying to create a calculated column in SharePoint 2007. I want it to return the year of the CreatedBy column date and set the day to be 1 and the month to be January the data type returned by the formula is of type Date. Any ideas how I can do…
van
  • 9,159
  • 19
  • 60
  • 93
5
votes
1 answer

Spotfire calculated column based on filter

I want to create a calculated column that is equal to the percent of the total of the previous column, but only for the rows that are selected. For example, the two columns below show rows where I've filtered for only the rows of interest. The sum…
avgara
  • 51
  • 1
  • 2
5
votes
3 answers

Identity key on varchar column - T-SQL

I want to know if I can create an Identity (auto increment on a Varchar column. and how can I make it a primary key and create foreign key references on other table. This is the code i have - CREATE TABLE Questions( QuestionID int IDENTITY…
Abey
  • 155
  • 1
  • 2
  • 9
5
votes
4 answers

Need report with the number of columns depending on date range parameter

I'm quite a newbie with SQL. I'm currently working on an Oracle database and I've created a report that pulls up data depending on the date range parameter. The code is as follows: SELECT DISTINCT C.CUSTOMER_CODE , MS.SALESMAN_NAME ,…
Cajetan
  • 55
  • 4
5
votes
2 answers

SQL Server 2005 Computed Column Result From Aggregate Of Another Table Field's Value

Sorry for the long question title. I guess I'm on to a loser on this one but on the off chance. Is it possible to make the calculation of a calculated field in a table the result of an aggregate function applied to a field in another table. i.e. You…
One Monkey
5
votes
1 answer

"Error validating formula" when adding Computed Column with CONVERT(DATE, column)

I am trying to add a computed column to a table via SSMS - I'd rather care not to get into the details on why the base column is a VARCHAR(10) and not a DATE and no, I'm not interested in changing it. When I enter the formula CONVERT(DATE,…
user166390
5
votes
2 answers

Excel VBA: how to check for calculated column?

Is there anyway to check in VBA if a specific column of a table (ListObject) in Excel is a calculated column (as in http://office.microsoft.com/en-us/excel-help/use-calculated-columns-in-an-excel-table-HA010342380.aspx)? Note that calculated columns…
user1139216
  • 109
  • 1
  • 8