472,101 Members | 1,471 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

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
Apr 8 '07 #1
2 7595
Try this query ....

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


Thanks,
Scarlet
Apr 9 '07 #2
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
Apr 10 '07 #3

Post your reply

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

Similar topics

reply views Thread by Brian Newsham | last post: by
9 posts views Thread by netpurpose | last post: by
2 posts views Thread by Chris DiTommaso | last post: by
1 post views Thread by USI Newsgroups | last post: by
reply views Thread by ferio | last post: by
2 posts views Thread by buzzy18 | last post: by

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.