Hi
This question should be really easy but I just cant do it!! I have a table below:
Code Group Test Price
56 1 1 2298
56 1 2 1215
56 1 3 1378
56 2 1 492
56 2 2 600
All I want to do is to select the Lowest Price per Group: eg
Code Group Test Price
56 1 2 1215
56 2 1 492
But this seems impossible if I want to include the 'Test' field. So i can get
Code Group Price
56 1 1215
56 2 492
But i wont know what the value of 'Test' is!
Can anyone help?
Thanks
3 1315
Hi
This question should be really easy but I just cant do it!! I have a table below:
Code Group Test Price
56 1 1 2298
56 1 2 1215
56 1 3 1378
56 2 1 492
56 2 2 600
All I want to do is to select the Lowest Price per Group: eg
Code Group Test Price
56 1 2 1215
56 2 1 492
But this seems impossible if I want to include the 'Test' field. So i can get
Code Group Price
56 1 1215
56 2 492
But i wont know what the value of 'Test' is!
Can anyone help?
Thanks
You can only do this if there is only 1 lowest price obviously. If this is the case then make 2 queries.
The first I called querytest1 -
SELECT TESTTABLE.Code, TESTTABLE.group, Min(TESTTABLE.price) AS MinOfprice
-
FROM TESTTABLE
-
GROUP BY TESTTABLE.Code, TESTTABLE.group;
-
Then create a new query based on TESTTABLE and querytest1 and join minofprice to price to get the test field you want, like this -
SELECT TESTTABLE.Code, TESTTABLE.group, TESTTABLE.test, TESTTABLE.price
-
FROM TESTTABLE INNER JOIN qryTest1 ON (TESTTABLE.price = qryTest1.MinOfprice) AND (TESTTABLE.group = qryTest1.group) AND (TESTTABLE.Code = qryTest1.Code);
-
-
Thanks Alot!! This seems to work!!
Seems a long way round but I am very grateful for the quick reply!!
Have been struggling with this for ages!!
Cheers
NeoPa 32,556
Expert Mod 16PB
From your test data, I assume you want to group on the Code AND Group fields.
[code]SELECT [code],
[Group],
Mid(Min(Format([Price],'0000000.00') & [Test]),11,99),
Min([Price])
FROM [YourTable]
GROUP BY Sign in to post your reply or Sign up for a free account.
Similar topics
by: The Bit Bandit |
last post by:
Hopefully someone can help me create a query that I'm having some
trouble with.
I have three tables: invoices, invoicedetails, invoicepayments
The fields are:
invoices
--------
InvoiceNo
|
by: Tony Williams |
last post by:
I have a database that hold s figures for each quarter. I want to create a
query whereby the user can ask for the running total of the data upto the
quarter they enter into a prompt. The database...
|
by: Darren |
last post by:
Hi,
I am trying to write an Aged Debtors report in MSquery, I have created
all of the columns sucessfully, I just need to have totals of each
column at the bottom of the report - how can this be...
|
by: New Guy |
last post by:
I'm trying to work with a system that somebody else built and I am
confounded by the following problem:
There is a table of payments and a table of charges. Each client has
charges and payments...
|
by: brm6546545 |
last post by:
I have a tblTax. It has fields InvoiceNum, TaxAuthority, TaxableTotal,
NonTaxableTotal, TaxCollected.
Sample data
1,county,10.00,0.00,0.40
1,city,10.00,0.00,0.10
2,state,0.00,15.00,0.15
...
|
by: MikeSA |
last post by:
Hi
I a trying to create a chart that reflects monthly cumulative totals from a query.
The query fields show sales opportunities forecasted invoice date (OppForInvDate), Opportunity Description and...
|
by: JJM0926 |
last post by:
I'm trying to create a running totals query in access 97. I have
followed the directions on how to do it from Microsofts website
article id 138911. I took their code they had and replaced it with...
|
by: Micheal |
last post by:
Greetings Access Group,
Being relatively new to Access, I try to work through problems on my own and have been very successful, although I have a conundrum that I have been working on for two days...
|
by: colin spalding |
last post by:
How do I design a totals query that instead of the following result
YearOfAcc PremiumGBP
2004 9,142,306.95
2004 1,481,153.21
2005 11,981,987.85
2006 20,653,195.20
2006 ...
|
by: Yesurbius |
last post by:
I am receiving the following error when attempting to run my query. In my mind - this error should not be happening - its a straight-forward query with a subquery. I am using Access 2003 with all...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
|
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...
| |