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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to multiply different data type values

Author  Topic 

sqldbaa
Starting Member

32 Posts

Posted - 2008-02-29 : 06:34:27
Hi ,

I have the below tables

Table 1 with columns

id int
price char
quantity int
date date

In this table, same id has several entries at different date.

table 2 with columns

groupid int
groupname char


table 3 with columns

id int
groupid int


I want the result as

id
groupname
sum(quantity * price) for each id

Please help me in writing a query for this

Thanks in advance

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-02-29 : 07:17:32
sum(quantity * cast(price as money))


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

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-02-29 : 07:17:43
Why is price a CHAR??? Always use the correct datatypes for your data, that is the #1 simplest, most important rule of database programming.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -