NYCPHP Meetup

NYPHP.org

[nycphp-talk] mySQL 3.23.41 SELECT syntax to get MAX(revenue) < 8411

Phil Powell soazine at erols.com
Mon Oct 6 23:55:50 EDT 2003


Before I go any further, allow me to show you the list of URLs and newsgroups I researched before posting this:

http://www.zend.com/htsearch.php?config=&words=mySQL+having+max+select+single-row&method=and&format=long&sort=score

http://www.mysql.com/doc/en/SELECT.html

http://www.google.com/custom?q=mysql+having+max+single+row&sa=Google+Search&cof=LW%3A125%3BL%3Ahttp%3A%2F%2Fnyphp.org%2Fimg%2Fnyphp.logo.gif%3BLH%3A91%3BAH%3Aleft%3BS%3Ahttp%3A%2F%2Fnyphp.org%3BAWFID%3Af52dcf93f3c7bdad%3B&domains=nyphp.org%3Blists.nyphp.org&sitesearch=nyphp.org

http://www.google.com/custom?q=mysql+having+max+single+row&sa=Google+Search&cof=LW%3A125%3BL%3Ahttp%3A%2F%2Fnyphp.org%2Fimg%2Fnyphp.logo.gif%3BLH%3A91%3BAH%3Aleft%3BS%3Ahttp%3A%2F%2Fnyphp.org%3BAWFID%3Af52dcf93f3c7bdad%3B&domains=nyphp.org%3Blists.nyphp.org&sitesearch=lists.nyphp.org

http://www.phpbuilder.com/search/?sort=Score&method=and&config=manual&restrict=&exclude=&words=mysql+having+max+single+row

http://www.phpfreaks.com/mysqlmanual/page/manual_Reference.html#SELECT

comp.lang.php

alt.php

mysql.users

Unfortunately, either due to an oversight on my part or due to not addressing this I have not found any solution to this (also posted to experts-exchange.com, to no avail).

I want to select the max(revenue) from bonus where revenue < 8411.  Here is the query I tried:

select revenue, bonus
from bonuses
where revenue < 8411
having max(revenue) < 8411

This produces no results, so, not understanding honestly (even after reading mysql.com ' s tutorials on WHERE vs HAVING), I used my "hammer-peg-into-hole" comprehension process and kept at it:

select revenue, bonuses
from bonuses
having max(revenue) < 8411

This produces too many results when I only need one.  I need to come up with a clean DB solution to this and I at this point just don't know what I would need to do to do it, sorry, I hope this is the best possible approach to the problem.

My last hurdle toward getting the shopping cart completed - I could have it all done tonight!

Phil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.nyphp.org/pipermail/talk/attachments/20031006/e380d70d/attachment.html>


More information about the talk mailing list