Reputation: 291
SQL is goofy sometimes ain't it? Right now I want to take two values from different column and compare the difference. Ex:
ColA | ColB | New column
1 | 0 | 1
2 | 5 | 3
3 | 10 | 7
What should I do i order to create this RAD new column?
Upvotes: 1
Views: 157
Reputation: 4960
Do you actually need a new column? Perhaps you just want access to this value in a select statement?
SELECT ColA, ColB, ABS(ColA - ColB) AS [New column]
FROM YourTable
Upvotes: 0
Reputation: 176124
You could use computed/calculated column:
ALTER TABLE tab_name
ADD new_column AS (ABS(ColB - ColA));
Upvotes: 2
Reputation: 687
Maybe something like this...
select ColA, ColB, ABS(ColA-ColB) as 'New column' from table
Upvotes: 0