473,800 Members | 2,342 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Show the highest and lowest price item sold this month.(SQL)

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

Expand|Select|Wrap|Line Numbers
  1.  SELECT  CarSales.Car_Reg,MAX (Purchased_Price) AS Highest_Sale
  2. FROM CarSales
  3. WHERE  Purchased_Price=(SELECT MIN(Purchased_Price)AS Smallest_Sale
  4.                                                                                         FROM CarSales)=
  5.  (((Month([Date_Of_Purchase]))=IIf(Month(Now())=1,12,Month(Now()))))
  6. GROUP BY [CarSales].[Car_Reg] ;
  7.  
Problem with the code is that it displays the highest price 2 the lowest price ordered by date, but they are all in 1 column.

I want it 2 display just the car reg, highest and lowest price all in separate columns.


CarReg Highest Price Lowest Price

cf63gd7 £8,000 £1500



All help welcome.
Dec 6 '06 #1
5 5455
MMcCarthy
14,534 Recognized Expert Moderator MVP
Try this ...

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT  CarSales.Car_Reg, MAX (Purchased_Price) AS Highest_Sale, MIN(Purchased_Price) AS Smallest_Sale
  3. FROM CarSales
  4. WHERE (((Month([Date_Of_Purchase]))=IIf(Month(Now())=1,12,Month(Now()))))
  5. GROUP BY [CarSales].[Car_Reg] ;
  6.  
Dec 6 '06 #2
owz
14 New Member
thanx very much, i didnt think it was that simple.
Dec 6 '06 #3
MMcCarthy
14,534 Recognized Expert Moderator MVP
thanx very much, i didnt think it was that simple.
No problem.

Mary
Dec 6 '06 #4
NeoPa
32,579 Recognized Expert Moderator MVP
Expand|Select|Wrap|Line Numbers
  1.  SELECT  CarSales.Car_Reg,MAX (Purchased_Price) AS Highest_Sale
  2. FROM CarSales
  3. WHERE  Purchased_Price=(SELECT MIN(Purchased_Price)AS Smallest_Sale
  4.                                                                                         FROM CarSales)=
  5.  (((Month([Date_Of_Purchase]))=IIf(Month(Now())=1,12,Month(Now()))))
  6. GROUP BY [CarSales].[Car_Reg] ;
Did you mean to exclude January completely from your query?
Dec 6 '06 #5
MMcCarthy
14,534 Recognized Expert Moderator MVP
Did you mean to exclude January completely from your query?
Ade right it should be:

Expand|Select|Wrap|Line Numbers
  1. WHERE (((Month([Date_Of_Purchase]))=IIf(Month(Now())=1,12,Month(Now())-1)))

Mary
Dec 7 '06 #6

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

Similar topics

2
1923
by: Steven | last post by:
Hi there, I have a list of values that I am displaying in a table (Not using a loop) I want to be able to put a graphic next to the item with the hightest price. I have all of the prices in a table. Any ideas?
12
11947
by: | last post by:
Does anyone know an easy way to put a current gold price on your own website? I've seen the graphic methods that Kitco.com offers, but I'd rather have it pull the value from some gold market system in text format. I found a website that's doing it, but don't know where to start in reverse engineering the code: http://www.goldinvestment.com/Purchasing/Scrap_Gold.asp Thanks
10
3148
by: Frederick Gotham | last post by:
Anyone want to give me a hand to write efficient algorithms for Highest Common Factor and Lowest Common Multiple? This is what I have so far... Caveat: I haven't gone over the following code in detail, so there might be a subtle bug lurking somewhere. unsigned HCF(unsigned const a, unsigned const b) { unsigned bigger,smaller;
17
7722
by: rhitz1218 | last post by:
Hi, I'm trying to create a function that will sort a number's digits from highest to lowest. For example 1000 - will become 0001 or 1234 to 4321
13
141308
by: td0g03 | last post by:
Hello again guys. I have a question. I'm working on a program for my class and I'm stuck on how to find the lowest and highest number of a user input. We aren't at arrays yet so that's out of the question, but what would be another way of finding the highest and lowest. I remember hearing something in the lines of "cout <<" in class, but forgot. Also I could try the if else statement, but would seem like alot of work. I hope I am making this...
2
7989
by: gizelle2101 | last post by:
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...
0
1355
by: 1 | last post by:
Dear friend, we sell all kinds of laptops and guitars . our product is a quantity best, the price is the lowest in the world, i think you will be interested in our product . thanks a lot! Our Website:http:// www.prs-123.com/ Msn: prs_cool_123@hotmail.com mail: prs_cool_123@yahoo.com.cn thanks for everyone good luck with everyone . %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Dear friend, we sell all kinds of laptops and...
23
2500
by: lionelm | last post by:
Item (upc, title, type, category, company, year, sellPrice) Purchase (receiptId, date, cid, name, card#, expire, expectedDate, deliveredDate) PurchaseItem (receiptId, upc, quantity) Stored (name, upc, stock) To show top selling item: The user provides a date and a number, say n. The system prints a list of the n best selling items on that day, by all the stores. For each best seller, the system shows the title, the company, the current...
6
5753
by: Patrick Fisher | last post by:
Hi I have tables from 12 suppliers each of whom can supply the same part, I need to be able to create a table or query containing a list of suppliers who can supply at the lowest price for each item. I am struggling with this, can anyone help. Thanks Patrick
0
9691
marktang
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...
0
9551
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10505
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10276
jinu1996
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...
0
10035
tracyyun
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...
1
7580
isladogs
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...
0
6813
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();...
0
5471
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...
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.