473,387 Members | 1,493 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

changing values based on top 3 highest numbers in a list

I have a module which lists the top 3 products on my website by views that week. Every week it resets to 0. I would like for the top product in this list to be discounted by 15 percent, the second by 10 percent and the third by 5 percent. The discounts are managed by a discount_id column. I can easily accomplish this but the problem is that the list is constantly changing and I need the old discount_id to be put back in when the product drops out of the top 3 list. So what I need in simple terms is:

if product is in top 3 list, copy discount_id to old_discount_id and then change discount_id. If product is no longer in top 3 list, copy old_discount_id over to discount_id. I also need it to distinguish between the different discount rate for each of the top 3 products. Is there a better way of doing this? Thanks for your time.
Oct 8 '11 #1
1 1323
YarrOfDoom
1,247 Expert 1GB
It might be more easy to have a second table with 3 records: the new discount_id's and their associated product id's.
Then use a LEFT JOIN (or a RIGHT JOIN, depending on your query) when you lookup the products table and need the discount_id column.
Oct 10 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: martin | last post by:
I needed a way to display calculated, multiple, changing values (numerical sums) as users interacted with the page, and do this without going back to the server to load the page again. What I...
0
by: Kevin Schneider | last post by:
Please forgive me if this is a bit off topic, but I haven't had any takers in other forums. With ASP.NET projects, is it possible to have VS.NET automatically change the configuration options of...
0
by: Stephen | last post by:
Hi Everyone I'm going to use my first <asp:CheckBoxList> control to create a list of selections which users can choose from and run a search against. In other words they are going to act as the...
4
by: Siemel Naran | last post by:
Hi. I have found one advantage of returning values through the argument list. It's that we have to store the return value. But when we return by value, we may forgot to store the return value. ...
2
by: RBohannon | last post by:
I'm using Access 2000 on Windows 2000. I have a DB of several exams and people who have taken them. I need to assign ranks to the people according to their scores (within each exam). I have...
2
by: Zlatko Matić | last post by:
Hello. How to reference selected values from a multi-select list box, as a criteria in a query ? Is it possible at all? Regards, Zlatko
2
by: elizann | last post by:
How do i enable several groups of radio buttons based on a list box selection for eg. function checkwork(){ var X = document.form2.notworking.value; if(X=="No"){ ...
4
by: someone124 | last post by:
Hi, everyone. I'm trying to find the lowest and the highest numbers that a user has had punched in. The code includes a user punching in 4 different numbers, each on a different line. I need help...
7
by: LSGKelly | last post by:
I am working on a query that I would like to get the top 4 values based on a group. Here is the SQL: SELECT qRenPercRept1.CountOfccName, qRenPercRept1.Merged, qRenPercRept1.ccName,...
2
by: Anne Finch | last post by:
I am having issues creating a menu-driven program that should accept integers and calculate the mean and median values and display them. I'm not having trouble calculating the Mean or Median, but I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.