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 2012 Forums
 Transact-SQL (2012)
 Simple Math in View

Author  Topic 

mimuk
Starting Member

19 Posts

Posted - 2013-09-06 : 07:38:38
Forgive me for not getting my head around this.
I have 3 columns when I select quant, pric, disc from dbo.ququoteitems table


quan pric disc
1 100 -50
1 50 -10
20 10 -50


I need to create a derived field in the view that shows the sale price
i.e in the first row 1 * 100 then apply discount of 50%.
The disc column includes a minus sign


quan pric disc total to show
1 100 -50 50
1 50 -10 45
20 10 -50 100


Cheers in advance

Mim

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-09-06 : 07:49:47

SELECT *, (quan*pric) + ((quan*pric)*disc/100) "total to show"
FROM dbo.ququoteitems


--
Chandu
Go to Top of Page

mimuk
Starting Member

19 Posts

Posted - 2013-09-06 : 07:56:07
Perfect Chandu
Thanks for the quick response
Go to Top of Page

bandi
Master Smack Fu Yak Hacker

2242 Posts

Posted - 2013-09-06 : 07:56:34
quote:
Originally posted by mimuk

Perfect Chandu
Thanks for the quick response


Welcome

--
Chandu
Go to Top of Page
   

- Advertisement -