Solved

total up fields and write to filed in sql

Posted on 2007-03-21
2
174 Views
Last Modified: 2010-05-18
I need to write an update query to total up 6 fields in a row and write them to one of the fields.

what I need is curmonth1 + curmonth2 + curmonth3 + curmonth4  + curmonth5 + curwages all put in the field curwages.   expamle   1 + 1+ 1 + 1+1+ 1 = 6 in the filed curwages.

I'd really would be greatful for some guildance with this problem

Thanks

0
Comment
Question by:running32
2 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 total points
ID: 18763619
update yourtable
   set curwages = curwages + curmonth1 + curmonth2 + curmonth3 + curmonth4 + curmonth5

if at least 1 of the values could be null, but a COALESCE(curmonthN , 0) instead of simply curmonthN
0
 

Author Comment

by:running32
ID: 18763827
Thank you
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now