473,387 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Domain Aggregate per record?

JustJim
407 Expert 256MB
I have a table for water monitoring sites, each site has a SiteNo (site number) field and in another table each site has details of a number of samples taken at that site, including the date taken, What I need is a query which gives me details of the sites with the first and last date on which a sample was taken for each site. The following code gets me the earlies sample in the sample table, but what do I put in the third part of the DMin to get it for each site?
Expand|Select|Wrap|Line Numbers
  1. EarliestSample: DMin("[Date]","tblSample")
It's got to be something like
Expand|Select|Wrap|Line Numbers
  1. "SiteNo = 'something'"
but what? Should I compare it to something else in the query
Expand|Select|Wrap|Line Numbers
  1. "SiteNo = SiteNo"
or something on the report where the query is the Control Source?

Thanks in advance, and

Go Mary, Go (9K!)
(Edit: Actually, everybody in the top 10 with the exception of JosAH and possibly r0 (and pbmods who hase just clocked one) are in the final stages of the next K. Way to go troops!)

Jim
Oct 5 '07 #1
4 1299
JConsulting
603 Expert 512MB
I have a table for water monitoring sites, each site has a SiteNo (site number) field and in another table each site has details of a number of samples taken at that site, including the date taken, What I need is a query which gives me details of the sites with the first and last date on which a sample was taken for each site. The following code gets me the earlies sample in the sample table, but what do I put in the third part of the DMin to get it for each site?
Expand|Select|Wrap|Line Numbers
  1. EarliestSample: DMin("[Date]","tblSample")
It's got to be something like
Expand|Select|Wrap|Line Numbers
  1. "SiteNo = 'something'"
but what? Should I compare it to something else in the query
Expand|Select|Wrap|Line Numbers
  1. "SiteNo = SiteNo"
or something on the report where the query is the Control Source?

Thanks in advance, and

Go Mary, Go (9K!)
(Edit: Actually, everybody in the top 10 with the exception of JosAH and possibly r0 (and pbmods who hase just clocked one) are in the final stages of the next K. Way to go troops!)

Jim
Hi Jim,
Add your primary table to your query grid. Add your Child table twice.
Join them all on the ID/FK field

Drag your ID field from your primary down to the query grid.
Drag your date field down from the 1st child table
drag your date field down from the 2nd child table

now use the group by thing...for the id
use the Min for the first date field
Use the Max for the second.

That's it!

Example

Expand|Select|Wrap|Line Numbers
  1. SELECT Table1.ID, Min(tblDateMax_1.date1) AS MinOfdate1, Max(tblDateMax_2.date2) AS MaxOfdate2
  2. FROM (Table1 INNER JOIN tblDateMax AS tblDateMax_1 ON Table1.ID = tblDateMax_1.ID) INNER JOIN tblDateMax AS tblDateMax_2 ON Table1.ID = tblDateMax_2.ID
  3. GROUP BY Table1.ID;
  4.  
J
Oct 5 '07 #2
JustJim
407 Expert 256MB
Hi Jim,
Add your primary table to your query grid. Add your Child table twice.
Join them all on the ID/FK field

Drag your ID field from your primary down to the query grid.
Drag your date field down from the 1st child table
drag your date field down from the 2nd child table

now use the group by thing...for the id
use the Min for the first date field
Use the Max for the second.

That's it!

J

You're good, you're darn good!
If you're the Houston, Tx of programming (I snuck a look at your profile), then I'm the San Angelo!

Thank you so much.

Jim
Oct 5 '07 #3
JConsulting
603 Expert 512MB
You're good, you're darn good!
If you're the Houston, Tx of programming (I snuck a look at your profile), then I'm the San Angelo!

Thank you so much.

Jim
Happy to help. And Thanks for the kudos!
J
Oct 5 '07 #4
JustJim
407 Expert 256MB
Happy to help. And Thanks for the kudos!
J
A supplementary question, if you're still watching this thread. Is it having the same table in a query twice that massively increases the running time of the query?

Jim
Oct 9 '07 #5

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

Similar topics

6
by: Charles Jamieson | last post by:
I am getting an inexplicable compile-time error message. Here is the code ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ #include <string> class CBerk { public:...
2
by: mike | last post by:
I have a location table that contains all North American zip codes, the city, county, state etc.. each record has a GUID. My problem is that several places in the US you will have a single city...
3
by: eddiec | last post by:
hi everyone, I have a report in an adp that uses aggregate functions in its record source and I am trying to figure out how to filter the records displayed in the report: DoCmd.OpenReport...
0
by: Not Me | last post by:
Hey, I have a report featuring a handful of subreports, a field taking values from the main record source, and a field in the report footer which displays the sum of values in said field. The...
3
by: cmay | last post by:
I am trying to build more applications using a more OO approach, with more seperation of business and presentation logic. One problem I am running into involves the design philosophy behind...
3
by: S P Arif Sahari Wibowo | last post by:
Hi! I would like to make an editable continous form, where most fields will be from table A and editable, except 1-3 fields are a glimpse into table B and uneditable. Table A relate to table B...
5
by: Dean | last post by:
Has anyone toiled with creating/using alternate domain aggregate functions? I have been messing with that a little. The one recordsource I have been working indicates I get 20 to 40% savings in...
2
by: Ian825 | last post by:
I need help writing a function for a program that is based upon the various operations of a matrix and I keep getting a "non-aggregate type" error. My guess is that I need to dereference my...
4
by: wrldruler | last post by:
Hello, First, I know it's against "Access Law" to save calculations in a table, but....I want/need to. I currently have sub-totals being calculated inside a form, using DMax, DCount, and...
4
by: vincibleman | last post by:
Howdy all, Working my way into SQL from Access. Think I might have the hang of the basics, but would really appreciate a sanity check. The stored procedure listed below works, but I can't help...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
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...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
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...
0
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,...
0
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...
0
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...

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.