Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8038729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:19:56+00:00 2026-06-05T03:19:56+00:00

Here is my situation: In my table i two fields: – Price (decimal (15,4)

  • 0

Here is my situation:

In my table i two fields:

- Price (decimal (15,4)
- TaxId (int)

TaxId value is not stored anywhere but there are only two values (actualy 3).

- 1 (8.5%)
- 2 (20%)
- NULL (no tax)

Now i need calculated column in my view that would calculate new price with tax included.

Any idea?

I went with something like:

SELECT...
CASE TaxId
   WHEN 1 THEN Price *1.085 AS test
   WHEN 2 THEN Price *1.2 AS test
   WHEN NULL THEN Price  AS test END
FROM...

UPDATE:

I have managed to execute the query with success.

CASE dbo.Table.TaxId WHEN 1 THEN dbo.Table.Price*1.085 WHEN 2 THEN dbo.Table.Price*1.2 ELSE dbo.Table.Price END AS CalcualtedPrice

Now I only need to make CalculatedPrice as decimal (15,4). How can i set that?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:19:58+00:00Added an answer on June 5, 2026 at 3:19 am

    Yes, google how to create a view in SQL Server and in the SELECT statement of your view multiply the Price column with the TaxId column. Since you have to consider the NULL value you should use COALESCE like this

    SELECT
    Price * (1 + COALESCE(TaxId/100), 0) AS newValue
    ...
    

    assuming that you have just ‘8.5’ in your column and not ‘8.5%’. Is it varchar or not?

    P.S.: COALESCE() returns the first non-null value

    UPDATE after question was edited:

    You just have to slightly modify your syntax

    SELECT 
    CAST(
    CASE 
       WHEN TaxId = 1 THEN Price *1.085
       WHEN TaxId = 2 THEN Price *1.2
       WHEN TaxId IS NULL THEN Price END AS decimal(15,4)
    ) AS CalculatedPrice
    FROM...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a situation where I've got file names stored in two fields in
Here is the situation: I have a table value function with a datetime parameter
Here the Situation . I am having 2 million records in table . Just
Here is my situation: I have one table that contains a list of drugs
Here's the situation: In my database i have a table with threads, and a
Here's the situation: I would like to iterate through a table with input controls,
So here is the situation. In my db table i have a column called
So here's my situation. I have a books table and authors table. An author
Okay, here's the situation: We have a table of about 50 columns (created by
Here is the situation, i have two tables tblProduct and tblCategory, what i am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.