Field Calculation SQL

S

Simon Gare

Hi,

would like to calculate field based on the entry in another i.e.; field3 =
field2 X field1



field1 field2 field3
10 2.5 25.00( =sum(field1*field2))

How do I go about this in the SQL DB itself, can it be done within field3?

Regards
Simon
 
B

Bob Barrows [MVP]

Simon said:
Hi,

would like to calculate field based on the entry in another i.e.;
field3 = field2 X field1



field1 field2 field3
10 2.5 25.00( =sum(field1*field2))

sum? you want an aggregate? if so, you can't show the details ...
Or are you thinking that you have to use sum() to do any calcualtion? if so,
that is not the case
How do I go about this in the SQL DB itself, can it be done within
field3?
It depends on the version of the database you are using (I assume it's SQL
Server ... never ask a database-related question without full specifying the
type and version of the rdbms you are using - it's almost always relevant)

In SQL7, your only option would be to create a view. Assuming you don't want
an aggregate:

CREATE VIEW MyView As
Select field1,field2,field1*field2 As Result
From table

In SQL 2000+, you have other options which I suggest you investigate either
by reading about them in Books Online or by posting to one of the sqlserver
newsgroups on this news server.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top