Calculate prices

Results 1 to 3 of 3

Thread: Calculate prices

  1. #1
    Join Date
    Dec 1969
    Posts
    5

    Default Calculate prices

    How can I calculate prices? Here&#039;s what I have: a table named tblProducts with fields including COST, DISCOUNT, and DISCOUNT TYPE. The problem is, some products are discounted by a dollar amount and others by a percent, like this:<BR>COST DISCOUNT DISCOUNT_TYPE<BR>300 50 %<BR>250 30 $<BR>300 50 $<BR><BR>I need to display the calculated PRICES on a web page. But the math equation changes if the DISCOUNT TYPE is $ or %. How do I construct the SQL to create a VIEW where I have "IFs". Like, IF DISCOUNT_TYPE=$ THEN PRICE = COST-DISCOUNT ELSE IF DISCOUNT_TYPE=% THEN PRICE = (COST-(COST*DISCOUNT/100))<BR><BR>I need to "link" the prices to the products (in tblProducts) and I need the web page to be able to SORT by PRICE. I have done this by storing the PRICES in the table itself, but I know that&#039;s poor design. Do I create a View? Stored Procedure?<BR><BR>Other problem is when I "globally" update the DISCOUNT (all products starting with "a" set the DISCOUNT to 35%). The change needs to be reflected in the PRICES and when the prices are stored in the table, they don&#039;t change all by themselves.

  2. #2
    Join Date
    Dec 1969
    Posts
    2,437

    Default Crossposted in ASP <eop>

    Don&#039;t.

  3. #3
    Join Date
    Dec 1969
    Posts
    5

    Default RE: Crossposted in ASP <eop>

    Sorry. Wasn&#039;t sure if this was an ASP or a SQL question.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •