SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Computation Problem. Please help!
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

sikharma13
Starting Member

Philippines
44 Posts

Posted - 10/26/2013 :  02:05:49  Show Profile  Reply with Quote
As i posted yesterday about my problem in MySQL, Sir visakh16
helped me.. although this is not a mysql site.. its an MS SQL,
still there are no difference when it comes to queries..

now, i have another question to ask.. i need to compute all the total
columns..

for example, i have table py_abcdeeh and the structure is..

DROP TABLE IF EXISTS "s_abcdeeh"."py_abcdeeh";
CREATE TABLE "s_abcdeeh"."py_abcdeeh" (
"PROVINCE" varchar(30) NOT NULL default '',
"MUNICIPALITY" varchar(30) NOT NULL default '',
"BARANGAY" varchar(30) NOT NULL default '',
"HOUSEHOLD_ID" varchar(30) NOT NULL default '',
"ENTRY_ID" varchar(12) NOT NULL default '',
"LASTNAME" varchar(35) NOT NULL default '',
"FIRSTNAME" varchar(35) NOT NULL default '',
"MIDDLENAME" varchar(35) NOT NULL default '',
"EXT_NAME" varchar(10) NOT NULL default '',
"NO_ELI_FOR_EDUC_GRANT" varchar(1) NOT NULL default '',
"NO_NCOM_EDUC_M1" varchar(5) NOT NULL default '',
"NO_NCOM_EDUC_M2" varchar(5) NOT NULL default '',
"EDUC_GRANT_M1" varchar(5) NOT NULL default '',
"EDUC_GRANT_M2" varchar(5) NOT NULL default '',
"T_EDUC_GRANT" varchar(5) NOT NULL default '',
"NO_NCOM_DEW" varchar(5) NOT NULL default '',
"NO_NCOM_HCV_M1" varchar(5) NOT NULL default '',
"NO_NCOM_HCV_M2" varchar(5) NOT NULL default '',
"NO_NCOM_BHCV" varchar(5) NOT NULL default '',
"FNCOM_M1" varchar(5) NOT NULL default '',
"FNCOM_M2" varchar(5) NOT NULL default '',
"HG_M1" varchar(5) NOT NULL default '',
"HG_M2" varchar(5) NOT NULL default '',
"H_GRANT" varchar(5) NOT NULL default '',
"TOTAL" varchar(5) NOT NULL default ''
) ENGINE=InnoDB DEFAULT CHARSET=latin1;

from educ_grant upto total.. how can i compute the desired value.
for example :

wherein the household id's are in select statement..

select * from py_abcdeeh

hhid------egrant1---egrant2---hgrant1----hgrant2---total.....
1232--------300-------200------500---------430------1430....
upto the last record the select statement is holding...

any help would gladly be appreciated! thank you so much!



VFP9.0 via MySQL 5.0

khtan
In (Som, Ni, Yak)

Singapore
17681 Posts

Posted - 10/26/2013 :  03:12:17  Show Profile  Reply with Quote
quote:
although this is not a mysql site.. its an MS SQL,
still there are no difference when it comes to queries

Yes. there is. Refer to http://troels.arvin.dk/db/rdbms/


KH
Time is always against us


Edited by - khtan on 10/26/2013 03:12:36
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 10/26/2013 :  04:39:39  Show Profile  Reply with Quote
simply this

UPDATE s_abcdeeh.py_abcdeeh
SET Total= EDUC_GRANT_M1 *1 + EDUC_GRANT_M2 + HG_M1 + HG_M2


Also the fields should be of type int and not varchar as they've numerical data as per you posted sample data

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.33 seconds. Powered By: Snitz Forums 2000