Jump to content

[SOLVED] Finding larger of 2 columns?


triphis

Recommended Posts

Hi there everyone ;)

 

Simple featured item script for an online store... Items have 2 columns, RETAIL and SALE (price, that is).

 

There is the option for the store owner to have the featured item to be the most expensive one... and I originally wrote the query to select the largest by RETAIL. However, obviously if that item is on sale for much less, it might not be the most expensive...

 

So, what I need is this:

 

SELECT id, LARGER(RETAIL,SALE) as highest FROM products ORDER BY highest DESC LIMIT 1

 

-------------------------------------

 

Is there a function to choose the larger of two as I have done above???

Thanks!!!

Link to comment
Share on other sites

Nope :)

 

I see my mistake.

 

Okay, let me try again: The items will not always be on sale (SALE = 0). However, if they are, then the SALE price is the price that the customer would pay, not the RETAIL price. So just ordering by RETAIL price would not be appropriate.

 

I am looking for a way to rank all by the price that *would* be paid by the customer, to find the actual most expensive item.

 

---------------------

 

Scenario:

 

Item 1 - retail=$300 / sale=$200

Item 2 - retail=$250 / sale=$0

 

I want my query to find Item 2 to be the most expensive :)

 

I hope that clears things up, and I hope you can still help me ^^

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.