Hi All,
I am working on a ranking Items in a query and I am stuck when I need to take more fields into account for the rank.
Currently I have a query that ranks [Location] by the [Date] they were entered for each [Item]. We have multiple locations for each item so the earliest date gets ranked 1 for each [Item]
The SQL below works pretty well so far: - SELECT a.Company, a.Item, a.Location, a.Status, a.Date, Count(*) AS Rank
-
FROM (SELECT Company, Item, Location, Status, Date
-
FROM qrySKULocation02
-
GROUP BY Company, Item, Location, Status, Date
-
) AS a INNER JOIN (SELECT Company, Item, Location, Status, Date
-
FROM qrySKULocation02
-
GROUP BY Company, Item, Location, Status, Date
-
) AS b ON (a.Item = b.Item) AND (a.Date >= b.Date)
-
GROUP BY a.Company, a.Item, a.Location, a.Status, a.Date
-
ORDER BY a.Company, a.Item, a.Date, Count(*);
-
But I need to expand the query and I would like to assign a rank number for each Item taking [Status] into account first, and then by [Date], and then by [Location]
Hopefully that was clear enough and someone can help me out.
Thanks in advance.
1 3896 zmbd 5,501
Expert Mod 4TB
I don't rank very often, and rarely on anything other than one field.
However, from what I remember you will need a series of union queries to tie all of your fields into one, and then do the ranking query against this new union.
just a general tip on ranking Allen Browne's Ranking Tutorial
Personally, when I end up having to create a ranking query, it's usually, but not always (IMHO), because I've not normalized the database properly; thus, it's worth a look to see if you can normalize the table structure a bit more!
Sign in to post your reply or Sign up for a free account.
Similar topics
by: ShyGuy |
last post by:
I have a table with 4 fields. Three are used for criteria.
I can get the DLookup to work with 1 criteria with the following but
can't get it to work with 2 or three.
NumofAppts = DLookup("",...
|
by: Greg Strong |
last post by:
Hello All,
In the past I've used a combo box with the 'row source' being an Access SQL
union query to select "All" or 1 for only 1 criteria in a query. An example
is as follows:
SELECT 0 As...
|
by: developing |
last post by:
Hello
How do I specify multiple criteria for FindFirst or FindRecord (or anything else) that takes the criteria from a form. (text field and number field)
edit:
this will be in the after...
|
by: JHNielson |
last post by:
I have a query that I'm trying to update with a dlookup with multiple criteria
This is the string:
EVNT_DT: DLookUp("","","( .EVNT_QTR=.) & (.=.)")
When i run it it says it can't find the...
|
by: Tlou5831 |
last post by:
I am attempting to compare 2 tables in my DB and find unmatched criteria.
There are 2 different fields in each database that need to be compared.
Tbl_AppUsers
Role Settings
INQ ...
|
by: kstevens |
last post by:
Please help. I know the sysntax is wrong. Here are some details. I am looking for the sum of past shipped items. I originally wrote this Dsum with only one criteria, but because of multiple...
|
by: Brendan Wolf |
last post by:
Happy Halloween all,
I have been struggling at work with a DLookup using multiple criteria. I would like a text box to display the results of a DLookup based on the values selected in three...
|
by: Brendan Wolf |
last post by:
Happy Halloween all,
I have been struggling at work with a DLookup using multiple criteria. I would like a text box to display the results of a DLookup based on the values selected in three...
|
by: DANNYOCEAN |
last post by:
I have a code that sucessfully calculates how many numbers are lower than for example 45 , for large sample number list.
But i´m looking for a code that have a COUNT function with MULTIPLE...
|
by: M0ji |
last post by:
I have created an update query to auto populate the value of one field based on the value of another field.
I have two fields "Level" and "Document"
if Document is A, Level needs to be 1
if...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |