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
 Other Forums
 MS Access
 Sum Total

Author  Topic 

Nasser
Starting Member

12 Posts

Posted - 2008-04-21 : 04:45:49
the database contain table its name is MovementTable

the table contain fileds F01,F02,F03,F04,F05,F06

the fileds contain
F01=KLM
F02=3
F03=5
F04=6
F05=747
F06=INDIA

SELECT f01,f02,f03,f04,f05,f06 ,SUM(f02,f03,f03) as total FROM MovementTable WHERE F01 = KLM

I WANT TO HAVE FILED IN REPORTS CONTAIN THE SUM OF F02,F03,F04

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-21 : 04:55:15
[code]SELECT f01,f02,f03,f04,f05,f06,(f02+f03+f03) as total FROM MovementTable WHERE F01 = 'KLM'[/code]

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Nasser
Starting Member

12 Posts

Posted - 2008-04-21 : 05:02:01
hello mr harsh_athalye

you code will give not give me the right answer

your code ,(f02+f03+f03) as total = 356

it should = 14

thanks for your help
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-21 : 05:07:19
How could simple addition of three fields gives you wrong sum? Post the query you tried.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Nasser
Starting Member

12 Posts

Posted - 2008-04-21 : 05:10:55
mr harsh_athalye

allow me to tell you that i'm ussing ur code throw VB.net 2003

does that make any diffrent ??!!

i did tryied same code you give me
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-21 : 05:13:18
No, it doesn't make any difference.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Nasser
Starting Member

12 Posts

Posted - 2008-04-21 : 05:52:38
so how it should fix
Go to Top of Page

AndrewMurphy
Master Smack Fu Yak Hacker

2916 Posts

Posted - 2008-04-21 : 08:26:50
(f02+f03+f03)
should this be
f02+f03+f04) ????


what values are in F02, F03 and F04???
Go to Top of Page

RyanRandall
Master Smack Fu Yak Hacker

1074 Posts

Posted - 2008-04-21 : 08:37:29
FYI all helpers - F02, F03 and F04 have varchar datatype. This thread is related...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=101350

Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-21 : 08:39:45
quote:
Originally posted by RyanRandall

FYI all helpers - F02, F03 and F04 have varchar datatype. This thread is related...

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=101350

Ryan Randall
Solutions are easy. Understanding the problem, now, that's the hard part.



Wow! So all it really was a concatenation!

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Nasser
Starting Member

12 Posts

Posted - 2008-04-21 : 10:40:19


thanks for helping me , i found the problem

the data type of filed is text , it should be Number so that sql statement work fine

SORRY FORM BATHRING YOU
Go to Top of Page
   

- Advertisement -