Query to get highest price and lowest price in database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gizelle2101
    New Member
    • Apr 2007
    • 4

    Query to get highest price and lowest price in database

    I've read the articles, but nothing is working. My database just lists jewelry by type and gems. I want to pull out the most expensive piece and the least expensive piece in one query.

    <code>
    mysql> SELECT type, gems, cost FROM inventory WHERE price=(SELECT MAX(cost) FROM inventory); </code>
    This gets me the most expensive piece. When I try adding:
    <code>
    AND price=(SELECT MIN(cost) FROM inventory);</code>
    I just get an error telling me my syntax is wrong.

    Can someone help be put this into one query?

    Thanks,
    Gizelle
  • ScarletPimpernal
    New Member
    • Mar 2007
    • 39

    #2
    Try this query ....

    SELECT type, gems, cost,MAX(price) ,MIN(price) FROM inventory GROUP BY germs.


    Thanks,
    Scarlet

    Comment

    • gizelle2101
      New Member
      • Apr 2007
      • 4

      #3
      Originally posted by ScarletPimperna l
      Try this query ....

      SELECT type, gems, cost,MAX(price) ,MIN(price) FROM inventory GROUP BY germs.


      Thanks,
      Scarlet
      Thank you this worked fine. You made it look so easy. Thanks again,
      Gizelle

      Comment

      Working...