473,729 Members | 1,971 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Query to get highest price and lowest price in database

4 New Member
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.

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:
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?

Apr 8 '07 #1
2 7971
39 New Member
Try this query ....

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

Apr 9 '07 #2
4 New Member
Try this query ....

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

Thank you this worked fine. You made it look so easy. Thanks again,
Apr 10 '07 #3

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

Similar topics

by: Brian Newsham | last post by:
------=_NextPart_000_004F_01C352B1.E5B8FA20 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi, I'm working on a PHP based website that loads custom pricing for users = where they logon.
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
by: Chris DiTommaso | last post by:
I have a table similar to the northwind products table. The difference is that I have products that may be supplied by multiple supplier. (i.e. there may be two or more rows that have the same product name, with different supplier,price,etc.) I need the following queries: 1. Show rows of all products that only have one supplier. 2. Show rows of all products that have multiple suppliers, but only show the 'preferred' supplier. (preferred...
by: USI Newsgroups | last post by:
It's me, one more time. My last request didn't quite filter all my records, I have one more field I need to evaluate in the script. DESCR TYPE SELL StartDate EndDate Number 65048 04 Price A 4/21/2004 4/26/2004 35456 65048 06 Price C 4/20/2004 4/27/2004 35459 65048 08 Price B 4/22/2004 4/28/2004 34559 65049 04 Price A ...
by: RBohannon | last post by:
I'm using Access 2000 on Windows 2000. I have a DB of several exams and people who have taken them. I need to assign ranks to the people according to their scores (within each exam). I have a select query written like this: SELECT ., Count(.) AS Tally, . FROM
by: ferio | last post by:
morning all, let me just go straight to the problem: I have Table "Product list" as below; ID Prod No Price 1 ABC-123 6.1 2 ABD-345 6.2 3 AHD-352 6.2 4 AHF-135 6.3 5 AYU-633 6.5
by: owz | last post by:
Hi again had some more problems, all help welcome. Access 2000, SQL My problem is as stated in the title. I want 2 display the highest and lowest priced car sold for this month. This is what I have. SELECT CarSales.Car_Reg,MAX (Purchased_Price) AS Highest_Sale FROM CarSales WHERE Purchased_Price=(SELECT MIN(Purchased_Price)AS Smallest_Sale FROM...
by: KevLe | last post by:
I'm building a log search function in c# for a certain management app and would like some help on the design how to solve this, here is my solution (on paper) so far: The log files are saved to disk, one file per date and one row "per logged event". Each row has a specific logged time (within the file's date) with different keys and values. The search filter query is built up via comboboxes and a datagridview. The datagridview is...
by: buzzy18 | last post by:
Hi all, I am using CakePHP to develop a bidding site. I have created a controller called 'daemons' and it performs 4 different tasks which I need to run continuously on the server every minute. I have set this up as 4 cron jobs but something is not working right and my crons just fail to work! Could be a problem with the controller, just not able to place it. My controller code is pasted below: <?php class DaemonsController extends...
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.