Hi ,
I want to add a new column with values populated based on values from existing column. How can I include the condition. Looking forward for your suggestion.
Regards,
Sajjan
Hi ,
I want to add a new column with values populated based on values from existing column. How can I include the condition. Looking forward for your suggestion.
Regards,
Sajjan
Hi,
I know that we can add a column but I am struggling to find if we can add values to the new column based on values from existing column. Hoping to get a solution.
Regards,
Sajjan.
Hello @sajjan.jindal,
What specifically are trying to accomplish? You can create computed columns for a number of cases. For example, below we are multiplying 2 values in a row and placing the result in a new column:
SELECT name, id, sales_per_quarter * average_sale AS average_sales_per_quarter
FROM sales_table
Thx for your response - I was able to use the case statement and add new columns
@ben, i am also trying to create new Field based on condition like
Lets say i have old_field new _field
1 1 ==> sum of 1+0 =1
3 4 ==> sum of 1+3 =4
7 11 ==> sum of 4+7 =11
how i i create new field like this through Query
you can achive it by using over window function
SELECT Id, DailyPoduction,
SUM (DailyPoduction) OVER (ORDER BY Id) AS CummulativePoduction
FROM MY_TABLE