Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2012 Forums
 Transact-SQL (2012)
 Simple Math in View
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mimuk
Starting Member

19 Posts

Posted - 09/06/2013 :  07:38:38  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 09/06/2013 :  07:49:47  Show Profile  Reply with Quote

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 - 09/06/2013 :  07:56:07  Show Profile  Reply with Quote
Perfect Chandu
Thanks for the quick response
Go to Top of Page

bandi
Flowing Fount of Yak Knowledge

India
2241 Posts

Posted - 09/06/2013 :  07:56:34  Show Profile  Reply with Quote
quote:
Originally posted by mimuk

Perfect Chandu
Thanks for the quick response


Welcome

--
Chandu
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000