user1086159
user1086159

Reputation: 1055

Inserting a new column into SQL

I have these queries:

SELECT *
FROM dbo.GRAUD_ProjectsByCostCategory

select right(CostCategoryId,14) as CostBreak 
from dbo.GRAUD_ProjectsByCostCategory

They work well in that they give me the correct data, but I would like to know how to combine the new column CostBreak into the table of results rather than as a separate query result.

An example of the results I get are as below:

enter image description here

Where I want them in the same table

Upvotes: 0

Views: 99

Answers (1)

Taryn
Taryn

Reputation: 247680

The data is coming from the same table so you should be able to just add that value to your initial query. You do not even have to perform a join to get it:

SELECT name, 
  description, 
  project,
  CostCategoryId, 
  right(CostCategoryId,14) as CostBreak 
FROM dbo.GRAUD_ProjectsByCostCategory 

Upvotes: 4

Related Questions