Queries :: How To Group Rankings By Date

Nov 25, 2014

I have used Allen Browne's suggested method of ranking to rank by the date each client settled... Now I need to group the rankings by the referring company as below... so it ranks each client referred by referral company from earliest to latest - like so:

ReferrerID___ClientID___TotalValue___BeatenBy (Ranking)
Intro1_______CatCo_____6/11/14________4
Intro1_______DogCo_____8/3/14_________1
Intro1_______FishCo_____17/5/14________3
Intro2_______AntCo_____11/1/14________2
Intro1_______PigCo______2/4/14_________2
Intro2_______BirdCo_____12/8/14________3
Intro2_______FrogCo_____6/1/14________1

My current SQL view of my query looks like this:

SELECT qryDates.ClientID,
qryDates.TotalValue,
(SELECT Count([ClientID])
AS HowMany
FROM qryDates AS Dupe

[Code] ....

View Replies


ADVERTISEMENT

Queries :: MAX Date Of Records - Add Another Field But Don't Want It To Group On It

Oct 28, 2014

I have a query that feeds another query. The first query needs to carry the Primary key, a secondary key (grouped by) a date (Maxed on) and an operator key (to group on) ...

At the moment I cant include the primary key because it groups on it and therefore every transaction is reports, my sql is -- How can I include the primary key MatterContactsMadeId and still get the max date for an operator within a matter

Code:

SELECT MatterContactsMade.MatterId, Max(MatterContactsMade.DueDate) AS MaxDueDate, MatterContactsMade.Operator
FROM MatterContactsMade
GROUP BY MatterContactsMade.MatterId, MatterContactsMade.Operator
HAVING (((Max(MatterContactsMade.DueDate))<=[Forms]![MattersBUpLogOptionsFrm]![txtBUpDate]) AND ((MatterContactsMade.Operator)=[Forms]![MattersBUpLogOptionsFrm]![txtOperator]))
ORDER BY MatterContactsMade.MatterId;

View 1 Replies View Related

Queries :: Group Results By Criteria Date Range

Sep 23, 2014

Below is a simplified example of what I'm trying to achieve with a parameter query.

The source table for the query contains two fields:

Reading_Date (short date) and Use_value (integer)

The parameter query sums Use_value between two dates for various date ranges specified as 'or' criteria. SQL as follows:

SELECT Sum(Table1.Use_Value) AS SumOfUse_Value
FROM Table1
WHERE (((Table1.Reading_Date) Between #1/1/2013# And #1/5/2013#)) OR (((Table1.Reading_Date) Between #1/1/2014# And #1/5/2014#));

This produces a single sum total, but I'd like the query to give a total per criteria date range. In other words to group results by criteria. As date ranges may span year change, grouping by year is not possible.

View 4 Replies View Related

Queries :: Group Overnight Shift Time Together For One Date

Oct 24, 2014

I am collecting data every hour on the hour and I would like to group this data according to Shift (A, B and C) by Date. The only problem I am having is- how can I keep the overnight shift together as one date? 10pm - 6am

I was able to do a simple query where I was able to assign an A, B, or C depending on the field with the Short Time format using nested IIF statements. From there I was able to group by shift (A, B, or C) per date. However the C Shift is split up.

Example. Can Sunday October 5th 10pm to Monday October 6th 6am be grouped as one date.

View 2 Replies View Related

Queries :: Count Number Of Tasks - Group By Date / Time In A Query

Aug 14, 2013

I want to count the number of tasks by department by week. I need the time so my date the task was added is formated as a date/time.

I created a query and added the department (twice so that I can group and count), and transaction date. I clicked on totals and added the count function under the department. I added this criteria to the task date: between [start date] and [end date].

Problem is that it's grouping by day and each one is different because all times are different. How do I group these by day and not time?

View 7 Replies View Related

Max Date On Group

Feb 27, 2008

How do I get just 41 records, each site, plus just the most recent event for that site?

Table 1, Sites (41 Records)
Table 2, Event (42 Records, 1 event for 40 sites, plus 2 events for 1 of the sites)

Totals Query 1, Group on SiteID from Sites, Select Max Date from Event. Good Result. (I get 41 records, 1 for each site, and the site with 2 events shows only the later event)

Query 2: Pull in Query 1, multiple fields from either the Sites Table or the Event Table. Good Result (41 records)

Query 3: Pull in Query 1 and both Tables. Everytime I get 1641 records. I've tried every possible join combination, changing query 1 from Dynaset to Snapshot, etc.

In a help screen I noticed that the sample shows a join with an infinity sign at one end, but I never get that graphic with my joins. Is that an old graphic, or am I missing something?

View 4 Replies View Related

Minimum Date With Group By

Oct 26, 2005

I wondered if anyone new how to return the following

Table of Data

ID|ID2|Date
----------------
1 | 1 | 20/01/05
2 | 1 | 21/01/05
3 | 1 | 19/01/05
4 | 2 | 20/01/05
5 | 2 | 25/01/05

I want to return the minimum date grouped by ID2, but with the corresponding ID i.e.

ID|ID2|Date
----------------
3 | 1 | 19/01/05
4 | 2 | 20/01/05

cheers for your help...

View 4 Replies View Related

Group By System Date

Dec 5, 2005

hi guys,I want to group a field in my query within a certain period of time, say 1 week. (e.g. between #12/5/2005# and #12/11/2005 23:00:00#) however I need to run this query every week.so I don't want to have to change the dates every week just to run the query.Is there a way to use the system's calendar date so that the values will be input automatically (i.e. to group between today and today-6 23:00:00)?? maybe using date() function or something??:confused: heaps n heaps of thx!!:D

View 2 Replies View Related

Group And Retreive Date By Month

Jul 5, 2005

Hi All.
In a query I grouped DATE by month Date:Format([Date],"yyyy mmm") to calculate visits in each month. My problem is: How to create dialog where user can enter date based only on YEAR and MONTH and enter in this dialog start_date and end_date?
Thanks.

View 1 Replies View Related

Problem With GROUP BY [Date Time]

Aug 30, 2007

Hi there,

I have a table called tblTransactions with columns called (among others) [Date Time], Ticker, Quantity, Price and Commission. Column [Date Time] contains both a date and a time.
I want to determine the commission paid per day. If I use the following code I still get all single trades on a day as the times at which the trades were exucuted are all different. Is it possible to group by full days only without having to change my database in order to determine the daily commission paid?


SELECT T.[Date Time], sum(Commission) AS TotalCommission
tblTransactions AS T
WHERE T.[Date Time]<=#04/17/07#
GROUP BY T.[Date Time];


Best regards,
JapanFreak

View 4 Replies View Related

Queries :: Changing Dates In A Group Of Queries

Jul 21, 2013

I have written a large number of queries to gather data for a quarterly monitoring form. How do I replace the dates to update them for next quarter.For example I have written a query which counts the number of new members who started in the period 01/04/2013 to 31/07/2013. How can I change this (and the other 200 queries) without opening them all individually and manually altering it. Is there an Access equivalent of Word's Find and Replace?By the way I am using Access 2000.

View 11 Replies View Related

Modules & VBA :: Option Group - IIF Date Return

May 2, 2014

I have a date field in a form fed by an option group. Most of the options return the correct values, but I'm having a hard time with this:

If the inspection date (in another form) is in Jan Feb or March, then return the date 1 Apr of the inspection year. If not, then return 1 Apr of the following year.

Here is the trouble line:

Code:
Case 2
IIf (Month([Forms]![FrmGeneralInspection]![txtInspectionDate]) <= 3), Me![txtReInspectionDate] = DateSerial(Year([Forms]![FrmGeneralInspection]![txtInspectionDate]) + 1, 4, 1), Me![txtReInspectionDate] = DateSerial(Year([Forms]![FrmGeneralInspection]![txtInspectionDate]) + 2, 4, 1)

View 4 Replies View Related

Populate Option Group When Date Field Is Entered

May 24, 2005

I have a form where users fill in a date resolved and click complete in the Option Group, it's default value is incomplete. I have a problem with the users forgetting to change it to complete when the enter the date resolved. Is there a way to change the option group value when the date resolved is entered?

View 6 Replies View Related

Populate Option Group When Date Field Is Entered

May 24, 2005

I have a form where users fill in a date resolved and click complete in the Option Group, it's default value is incomplete. I have a problem with the users forgetting to change it to complete when the enter the date resolved. Is there a way to change the option group value when the date resolved is entered?

--- OR ---

Can it notify the user that they need to change the Option Group?

View 3 Replies View Related

Forms :: Subform Filtered By Date / Group-by Category?

Mar 9, 2014

Table: Transactions: ID,Date,Title,Category,Value, Budget Name
Table: Budget: Budget Name
Budget Years: Budget Name, Date From, Date To

Form entitles Budget, Fields : Date From, Date To, Budget Name

So within the form budget I have a subform which I want to group the categories and get a total value. THE tricky part is, I only want it to include values from the budget specified in the form and the date range of the form.

View 1 Replies View Related

Run Query That Will Group All Records By Company And By Date And Provide Sum Of QTY

Jan 17, 2013

I have a table (table1)that table has several columns: company / Qty / date / ERT...I want to be able to run a query that will group all the records by Company and by date and provide the sum of QTY - as well as the cumulative totals for each company and date.

My query looks like this:
amonth: MONTH CODE
Group By
assending

Field 1: Alias: Company
Group by

Ascending

Field 2: QTY
Table1
Sum

Field 3: Runtot: DSum("qty","table1","[month code]=" & [amonth] & " And [company]=" & [alias] & "")..I have the query set up - but my runtotal Dsum formula is giving me grief - specifically a #ERROR and I can't figure it out..I basically want it to look like this:

A company 15/Nov/2012 10 10
A Company 16/Nov/2012 10 20
B Company 12/Jan/2012 15 15
B Company 21/Mar/2012 5 20

View 3 Replies View Related

Queries :: Top N Per Group

Jun 19, 2014

I have been trying endlessly to get this working but to no avail. I have looked and used sample codes posted on the net.

I am trying to get top 1 [route_list_code] per [works_order_number]

I have attached three images:

- Query as isQL code
- Query with top n in criteria (pulling wrong information and its just by coincidence that the two records shown are split by group)

The code appears to just pull top # record (not per group)

as is.JPG
SQL code.JPG
query with top n in criteria.JPG

View 2 Replies View Related

View Queries By Group

Mar 8, 2012

I have moved from Access 2003 to 2010. In Access 2003 I was able to create query groups that contained shortcuts to queries in the main database. This worked great for us because we did not want to create user interfaces that required support- but we could have multiple queries in a database and have users look only in their query group.

The database I am using was created in 2003 and had those groups. Is there a way to view, edit and create a similar view in 2010?

View 3 Replies View Related

Queries :: Top N Records By Volume / Group

Sep 6, 2013

I have a table which holds parts sales data for 6 individual dealers, and I basically want to be able to produce a report which details the top 10 selling products by volume by group. I can produce a query which gives me the top 10 results of ALL of my groups accumulated, but really need this to be split by group, and would prefer not to create 6 different queries to obtain the data.

My table (tbl_Part Sales by Dealer) has the following fields:

Dealer Code
Part
Description
Volume
Sales

So I'd like the results to show the top Part sales by Volume, for each of the (6) Dealer Codes within the table.

View 1 Replies View Related

Queries :: List Latest In Each Group

Mar 23, 2013

I have a table of SOPs/WIs. Each, with time, gets a new version - this I keep in the child table.

tblVersions
------------
VersionID (PK)
SOPID(FK)
Version (integer)
IssueDate (date)

I want to make a list of the currently valid versions, i.e. for each SOPID pick the VersionID with the latest date.

One can do many things with subqueries and Max - functions, but after some experimentation I have stumbled upon this:

Code:
SELECT Last(tblTest.VersionID) AS LastOfVersionID
FROM tblTest
WHERE (((tblTest.IssueDate)<Date()-10))
GROUP BY tblTest.SOPID;

The function Last has a bit tricky reputation and description on the web. It does yields the right result in my testcase though , see the attached db - run query3.

Query3

Code:
LastOfVersionID
100
90
20
40
666
888
55
8

Update:
Well, it isn't. Just changing the VersionID numbers to something other than an ascending sequence renders an incorrect result with the above query. So what is the best way to get the desired result? (Access 2007)

View 4 Replies View Related

Queries :: Running Count Within Group

Sep 15, 2014

I have data like so:

Code:
SubjectID VisitID
1 5
1 5
2 7
2 7
2 9
2 9
etc

And need to return a running count for the number of visits per subject, so:

Code:
SubjectID VisitID VisitCount
1 5 1
1 5 1
2 7 1
2 7 1
2 9 2
2 9 2
etc.

I'd like to use DCount and have tried all variations of the following, but none of them returns the correct number:

VisitNumber: DCount("*","mytable","VisitID >= " & [VisitID] & " AND SubjectID =" & [SubjectID])

View 4 Replies View Related

Queries :: Get TableB To TableA Without Using Group By

Oct 18, 2014

MAX ID/date. I need to get TableB to TableA without using Group by.

Code:
TableA:
ID name1 name2 dt
1 n1A n2A 1/1/2010
2 n1A n2B 1/1/2010
3 n1C n2C 3/12/2011
4 n1D n2D 5/03/2013
5 n1D n2E 6/7/2014
6 n1D n2F 8/12/2011
.
.

Code:
TableB:
ID name1 name2 dt
2 n1A n2B 1/1/2010
3 n1C n2C 3/12/2011
5 n1D n2E 6/7/2014
etc

View 3 Replies View Related

Queries :: Group By Function In A Query

Apr 8, 2014

I'm having trouble using the "group by" function in my query. The option in design view is not showing up and I'm not able to figure out what I'm doing wrong. What is there in design view is Field, Table, Sort, Show, Criteria, Or. I seem to be missing the "Totals" option.

View 2 Replies View Related

Queries :: Sum Multiple Columns And Group?

Jan 15, 2014

I have a table that looks something like this in structure:

P_date (date)
Location_No (integer)
Invoice_type_A (integer)
Invoice_type_B (integer)
Invoice_type_C (integer)
Invoice_type_D (integer)

I want to create a query which shows the sum of the number of all four invoice types for a specific date regardless of the Location_No. By putting something like "Invoices_total: Invoice_type_A + Invoice_type_B + Invoice_type_C + Invoice_type_D" in the top field I am able to get the query to show me the total number of invoices per date AND location, but I would like the total number of invoices for a given date regardless of location number. How can this be done?

View 3 Replies View Related

Queries :: Query Group By Hours

Aug 10, 2014

I have a table with a list of records, each record has a timeFrom this I have a query, what I would like the query to do, is group the records in the query by hours.

View 1 Replies View Related

Queries :: One To Many Table Group And Count

Jul 6, 2013

I have 2 tables. tblOrders and tblOrdersItems. tblOrdersItems is the child and tbl Orders is the parent. the linking field is OrderID.

I am wanting to count all the OrderID in tblOrders. the criteria i need is EmployeeListID which is stored in tblOrdersItems.

When I put these tables into query design, add the criteria, grouping(see below)

Code:
SELECT tblOrders.OrderID
FROM tblEmployeeList INNER JOIN (tblOrders INNER JOIN tblOrdersItems ON tblOrders.OrderID = tblOrdersItems.OrderID) ON tblEmployeeList.EmployeeListID = tblOrdersItems.Employee
WHERE (((tblOrders.OrderDate)>Date()) AND ((tblEmployeeList.EmployeeListID)=[Forms]![rptReportsMainScreen]![txtEmployees]))
GROUP BY tblOrders.OrderID;

I get (record count at bottom of query screen) 87 records. then i add a field to give me the count so i can then use it i get many more.

How to get the count working. i have uploaded the relevant tbl and my attempted query.

View 9 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved