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

Computed columns in SQLCLR project in Visual Studio 2010

It appears that MS has a bug when dealing with VS 2010 SQL CLR project and computed columns. I am using Pre/PostDeployScript.sql to drop/add the computed column. However, if I try to deploy from VS2010 it, I get dependency errors. The same project…
laconicdev
  • 6,360
  • 11
  • 63
  • 89
11
votes
4 answers

SQL Server, how to merge two columns into one column?

I have a SQL query SELECT TABLE_SCHEMA + TABLE_NAME AS ColumnZ FROM information_schema.tables I want the result should be table_Schema.table_name. help me please!!
user3807363
  • 143
  • 1
  • 1
  • 5
11
votes
3 answers

calculate Row Wise Sum - Sql server

This is My table : ID Q1 Q2 Q3 Q4 ---------------------------------------------------------------- 20130712 NULL 728.63 NULL NULL 20130712 8881.55 9673.68 …
Uday
  • 151
  • 1
  • 2
  • 9
10
votes
2 answers

postgresql calculate sum of a resultset

Is there any built in function in postgresql to get the sum of of a column. Just a simple example CREATE TABLE sample_table (a INTEGER, b REAL); INSERT INTO sample_table (a, b) VALUES (5, 7.22); INSERT INTO sample_table (a, b) VALUES (5,…
Steinthor.palsson
  • 6,286
  • 13
  • 44
  • 51
10
votes
7 answers

Alter SQL Function Referenced by Computed Column

If you set up a table's column to be a computed column whose Formula calls a Function, it becomes a pain to change that underlying Function. With every change, you have to find every single column whose Formula that references the Function, remove…
10
votes
2 answers

matching for group (Expressions) in same column in Spotfire

Regarding the previous question which I have posted: calculation the difference for same column for the specific rows in Spotfire I have a new problem for it, below is the sample: The new function that i want to realize is, searching for the next…
ZAWD
  • 651
  • 7
  • 31
10
votes
3 answers

How to put foreign key constraints on a computed fields in sql server?

Table A has a computed field called Computed1. It's persisted and not null. Also, it always computes to an expression which is char(50). It's also unique and has a unique key constraint on it. Table B has a field RefersToComputed1, which should…
Asaf R
  • 6,880
  • 9
  • 47
  • 69
10
votes
7 answers

Filling data frame with previous row value

I have a data frame that has 2 columns. column1 has random numbers in column2 is a place holding column for what i want column3 to look like random temp 0.502423373 1 0.687594055 0 0.741883739 0 0.445364032 0 0.50626137 0.5 0.516364981…
user2813055
  • 283
  • 4
  • 13
10
votes
5 answers

SQL Server - INSERT failed because of 'ARITHABORT'

I use NHibernate and SQL Server 2005 and I have an index on a computed column in one of my tables. My problem is that when I insert a record to that table I get the following error: INSERT failed because the following SET options have incorrect…
9
votes
2 answers

Calculated Column in SQL Server

I have my data in table as: id Author_ID Research_Area Category_ID Paper_Count Paper_Year Rank --------------------------------------------------------------------------------- 1 677 feature extraction 8 1 …
maliks
  • 1,102
  • 3
  • 18
  • 42
9
votes
4 answers

Invalid column name error in WHERE clause, column selected with CASE

I have a (rather complicated) SQL statement where I select data from lots of different tables, and to cope with a bad legacy data structure, I have a couple of custom columns that get their values based on values from other columns. I have…
Tomas Aschan
  • 58,548
  • 56
  • 243
  • 402
9
votes
1 answer

Sum column with condition and display in row

I would like to sum a column with multiple condition and display all the result in rows I have a table as Status Amount pending 100 Success 50 pending 20 failure 80 success 20 Now I would like to find…
newcomer
  • 467
  • 6
  • 18
8
votes
1 answer

Instead Trigger or Calculated Column? which is better?

I was wondering if there was any performance difference between the two approaches below. Basically, the issue is we allow spaces and dashes in an id but certain legacy applications are unable to use these so they are stripped out. As far as I can…
Eoin O
  • 83
  • 1
  • 4
8
votes
1 answer

Is it possible to update a column(automatically) with "current_timestamp" in PostgreSQL using "Generated Columns"?

Is it possible to update a column (automatically) with "current_timestamp" in PostgreSQL using "Generated Columns", whenever the row gets update? At present, I am using trigger to update the audit field last_update_date. But I am planning to switch…
Thirumal
  • 8,280
  • 11
  • 53
  • 103
8
votes
2 answers

turn on/off automatic calculation in only a few columns in Excel

In excel I have a worksheet with over 30,000 rows. Sample data is shown in the image below. About a dozen of the columns have formulas which really slow down the work whenever I update a cell. I would like to use VBA code to turn off automatic…
Danny
  • 554
  • 1
  • 6
  • 17