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
 General SQL Server Forums
 New to SQL Server Programming
 Work out a discount based on a percentage?

Author  Topic 

jackmac
Starting Member

2 Posts

Posted - 2005-09-30 : 05:35:52
Hi all,

Hopefully a nice easy one to begin with. I have an access database which I use to build my web pages - I use sql to extract products which meet certain criteria then the pages are automatically generated. I can extract the data without any problem. An example I use is shown below:

===================================================
SELECT * FROM products WHERE products.group = 'LCD-HDTV' AND status = 'LIVE' AND tradeprice > 0 AND description3 > '' ORDER BY diagonal, tradeprice, description3
===================================================

I now want to get it to work out a discount of 1% on the products shown using the tradeprice field. I've tried many times using the SELECT and SUM functions but am not getting the syntax correct. Any help would be very much appreciated.

TIA

Jackmac

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2005-09-30 : 05:47:00
is this sql server sql
or access sql?
because there is an access forum here that will get you faster help if it's access
but it's something like:
iif(your condition for discount, tradeprice*0.99, tradeprice)


Go with the flow & have fun! Else fight the flow
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-09-30 : 05:47:43
If the tradeprice is 100 then do you want to show it as 99?
If so use this

Select OtherColumns, tradeprice-(tradeprice*0.01) from products WHERE products.group = 'LCD-HDTV' AND status = 'LIVE' AND tradeprice > 0 AND description3 > '' ORDER BY diagonal, tradeprice, description3



Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -