469,138 Members | 1,363 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,138 developers. It's quick & easy.

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 6788
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
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.