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.
| Author |
Topic |
|
oraclelady
Starting Member
1 Post |
Posted - 2006-01-25 : 15:07:40
|
| I am trying to figure how write sql statement that will give the total cost. unit price * quantity - discount = total cost Unit price = 9.8 quantity = 30discount = 0.15 |
|
|
Srinika
Master Smack Fu Yak Hacker
1378 Posts |
Posted - 2006-01-25 : 16:34:31
|
U want that to be done in MS SQL Server?and since u gave only one set of data, I think best way to use a calculatorOr if u want u can do something like following ;-- of course u may need to define the variables firstSet @Unitprice = 9.8Set @quantity = 30Set @discount = 0.15Print (@Unitprice * @quantity ) * (1 - @discount )ORIf u want to do this for a table / fields - u should have given the table & field names along with some sample data & expected results |
 |
|
|
Frank Kalis
Constraint Violating Yak Guru
413 Posts |
Posted - 2006-01-26 : 03:26:03
|
Looks like an example straight from the Northwind database  SELECT UnitPrice * Quantity * (1 - Discount) AS "Total Cost" FROM [Order Details] --Frank KalisMicrosoft SQL Server MVPhttp://www.insidesql.deHeute schon gebloggt? http://www.insidesql.de/blogs |
 |
|
|
|
|
|