Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 sum in sql server

Author  Topic 

rameshgoudd
Starting Member

13 Posts

Posted - 2008-02-28 : 03:56:29
hi All,


i have the two fields in my database table..one is aprincome and second is mayincome.

in this fields some times i wil enter the numeric values like 20 or 30 and some times i wil enter the values like percentage like 10%

for this which dataype i have to give?

and second one is how to add the aprincome and mayincome values(like aprincome+mayincome)..
thanks and regards

ram

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-02-28 : 04:10:37
quote:
Originally posted by rameshgoudd

hi All,


i have the two fields in my database table..one is aprincome and second is mayincome.

in this fields some times i wil enter the numeric values like 20 or 30 and some times i wil enter the values like percentage like 10%

for this which dataype i have to give?

and second one is how to add the aprincome and mayincome values(like aprincome+mayincome)..
thanks and regards

ram


Why are using this field to store two types of values? Also how do you distinguish b/w % & other values especially while taking sum? do you really want to sum % values ?
Go to Top of Page

rameshgoudd
Starting Member

13 Posts

Posted - 2008-02-28 : 04:24:44
quote:
Originally posted by visakh16

quote:
Originally posted by rameshgoudd

hi All,


i have the two fields in my database table..one is aprincome and second is mayincome.

in this fields some times i wil enter the numeric values like 20 or 30 and some times i wil enter the values like percentage like 10%

for this which dataype i have to give?

and second one is how to add the aprincome and mayincome values(like aprincome+mayincome)..
thanks and regards

ram


Why are using this field to store two types of values? Also how do you distinguish b/w % & other values especially while taking sum? do you really want to sum % values ?



in my userinterface i wrote the coding like this ..if he enters the numeric in the first textbox(aprincome related box)..he has to enter the numeric value only in the next textbox(means mayincome)...otherwise if he enters the percengae value in the first textbox..he has to enter the percentage value only in the next textbox..
now how will add these aprincome and mayincome values.

Ram
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-28 : 04:38:12
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

readysetstop
Posting Yak Master

123 Posts

Posted - 2008-02-28 : 07:00:47
A percentage value of what? I don't understand the requirement, here.

Pick a method and stick to it. If you want numeric, stick with numeric. Mix and matching input is a recipe for bad data. (In my opinion...)

____________________________________________________________________________________
"Believe in those who are seeking the truth. Doubt those who say they have found it." -Andre Gide
Go to Top of Page
   

- Advertisement -