Is there a way to create a calculated column in a table like this, or is
there a better way to accomplish this task? I've tried, but SQL keeps
adjusting my precedence and it goofs up the formula:
Let's say the column name is "NetPrice". I want to deduct the discounted
amount from the total to arrive at the net price. Discount is a decimal
value, ie: 25% = .25.
[TotalPrice] - ([TotPrice] * [Discount])Oops, typo below. Should be: [TotalPrice] - ([TotalPrice] * [Discount])
"Bill Hicks" <waylien_no_spam@.yahoo.com> wrote in message
news:uJhvc2lnGHA.4668@.TK2MSFTNGP02.phx.gbl...
> Is there a way to create a calculated column in a table like this, or is
> there a better way to accomplish this task? I've tried, but SQL keeps
> adjusting my precedence and it goofs up the formula:
> Let's say the column name is "NetPrice". I want to deduct the discounted
> amount from the total to arrive at the net price. Discount is a decimal
> value, ie: 25% = .25.
> [TotalPrice] - ([TotPrice] * [Discount])
>|||Bill
See if this helps
CREATE TABLE #Test (
TotalPrice DECIMAL, Discount DECIMAL,
NetPrice AS [TotalPrice] - ([TotalPrice] * [Discount]))
INSERT INTO #Test (TotalPrice,Discount) VALUES (50,15)
SELECT * FROM #Test
"Bill Hicks" <waylien_no_spam@.yahoo.com> wrote in message
news:uJhvc2lnGHA.4668@.TK2MSFTNGP02.phx.gbl...
> Is there a way to create a calculated column in a table like this, or is
> there a better way to accomplish this task? I've tried, but SQL keeps
> adjusting my precedence and it goofs up the formula:
> Let's say the column name is "NetPrice". I want to deduct the discounted
> amount from the total to arrive at the net price. Discount is a decimal
> value, ie: 25% = .25.
> [TotalPrice] - ([TotPrice] * [Discount])
>|||Thanks Uri. I think I was entering something incorrectly when I originally
entered the formula into the table designer.
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:ePsmpBmnGHA.764@.TK2MSFTNGP03.phx.gbl...
> Bill
> See if this helps
> CREATE TABLE #Test (
> TotalPrice DECIMAL, Discount DECIMAL,
> NetPrice AS [TotalPrice] - ([TotalPrice] * [Discount]))
>
> INSERT INTO #Test (TotalPrice,Discount) VALUES (50,15)
> SELECT * FROM #Test
>
> "Bill Hicks" <waylien_no_spam@.yahoo.com> wrote in message
> news:uJhvc2lnGHA.4668@.TK2MSFTNGP02.phx.gbl...
>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment