October 27, 2014 at 12:57 pm
Hi
I have multiple columns around 10
i am writing an update statement which doesn't update any of the rows
update table
set column11=isnull(columnA,0)+isnull(columnb,0)+...
where quarter='Q3'
also tried...
update table
set column11=SUM(COALESCE(column1,0) + COALESCE(column2,0))
where quarter='Q3'
both doesn't update column11. please help
October 27, 2014 at 1:22 pm
do you get any results when you select rows using the same where clause?
October 27, 2014 at 1:22 pm
Maybe some explanation what you are trying to do is needed.
Preferably in the form of table DDL, sample data and desired output.
See the link in my signature about asking questions.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
October 27, 2014 at 1:26 pm
batgirl (10/27/2014)
do you get any results when you select rows using the same where clause?
The rephrase the above question, what do you get when you run the query below?
SELECT * FROM table WHERE quarter = 'Q3'
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
October 28, 2014 at 9:02 am
Somehow it worked after deleting the data and imported the new data to the table and re-executed the below query.
update table
set column11=isnull(columnA,0)+isnull(columnb,0)+...
where quarter='Q3'
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply