473,405 Members | 2,287 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,405 software developers and data experts.

Finding the lastest date for an Inspecetion

I am trying to query the last/latest investigation for a facility using a date field. Each facility will have different types of investigations, I only want the last investigation performed. For the example below I only want to see ABC Day Care 11/5/07.

FACILITY
ABC Day Care

INVESTIGATIONS
1/1/06
4/18/07
11/5/07
Nov 30 '07 #1
3 1119
Rabbit
12,516 Expert Mod 8TB
Depends on where you're trying to use it. Either a Max() aggregate query or a DMax() function call.
Nov 30 '07 #2
I don't understand what you are asking. Will you explain further? Here is the SQL that I am working on.
Expand|Select|Wrap|Line Numbers
  1. SELECT CCL_EMPLOYEE.NBR_REGION, CCL_EMPLOYEE.NBR_UNIT AS Unit, ([CCL_EMPLOYEE.NM_LAST] & ", " & [CCL_EMPLOYEE.NM_FIRST]) AS Employee, CCL_FACILITY.NBR_FCLTY AS [Facility #], CCL_FACILITY.NM_FCLTY AS [Name of Facility], CCL_FACILITY.CD_FCLTY_TYPE AS [Op Type], CCL_INSPECTION.DT_BEGIN_INSPCTN AS [Date Began], CCL_INSPECTION.DT_END_INSPCTN AS [Date End], CCL_INSPECTION.CD_INSPCTN_TYPE AS [Ins Type]
  2. FROM ((((CCL_FACILITY INNER JOIN CCL_INSPECTION ON CCL_FACILITY.ID_FCLTY = CCL_INSPECTION.ID_FCLTY) INNER JOIN CCL_CODE_TABLE_ROW ON CCL_FACILITY.CD_FCLTY_TYPE = CCL_CODE_TABLE_ROW.CD_CODE) INNER JOIN CCL_CODE_TABLE_ROW AS CCL_CODE_TABLE_ROW_1 ON CCL_INSPECTION.CD_INSPCTN_TYPE = CCL_CODE_TABLE_ROW_1.CD_CODE) INNER JOIN CCL_FACILITY_ADDRESS ON CCL_FACILITY.ID_FCLTY = CCL_FACILITY_ADDRESS.ID_FCLTY) INNER JOIN CCL_EMPLOYEE ON CCL_INSPECTION.ID_EMPLYEE = CCL_EMPLOYEE.ID_EMPLYEE
  3. WHERE (((CCL_FACILITY.NBR_FCLTY)=510923 Or (CCL_FACILITY.NBR_FCLTY)=556373 Or (CCL_FACILITY.NBR_FCLTY)=860960 Or (CCL_FACILITY.NBR_FCLTY)=876183 Or (CCL_FACILITY.NBR_FCLTY)=558679 Or (CCL_FACILITY.NBR_FCLTY)=310307 Or (CCL_FACILITY.NBR_FCLTY)=401626 Or (CCL_FACILITY.NBR_FCLTY)=414127 Or (CCL_FACILITY.NBR_FCLTY)=500833 Or (CCL_FACILITY.NBR_FCLTY)=865154 Or (CCL_FACILITY.NBR_FCLTY)=853481 Or (CCL_FACILITY.NBR_FCLTY)=537436 Or (CCL_FACILITY.NBR_FCLTY)=540032 Or (CCL_FACILITY.NBR_FCLTY)=531810 Or (CCL_FACILITY.NBR_FCLTY)=502793 Or (CCL_FACILITY.NBR_FCLTY)=517369 Or (CCL_FACILITY.NBR_FCLTY)=501967 Or (CCL_FACILITY.NBR_FCLTY)=509294 Or (CCL_FACILITY.NBR_FCLTY)=867435 Or (CCL_FACILITY.NBR_FCLTY)=816647 Or (CCL_FACILITY.NBR_FCLTY)=558935 Or (CCL_FACILITY.NBR_FCLTY)=547134 Or (CCL_FACILITY.NBR_FCLTY)=543233 Or (CCL_FACILITY.NBR_FCLTY)=532226 Or (CCL_FACILITY.NBR_FCLTY)=516844 Or (CCL_FACILITY.NBR_FCLTY)=523808 Or (CCL_FACILITY.NBR_FCLTY)=516853 Or (CCL_FACILITY.NBR_FCLTY)=523211 Or (CCL_FACILITY.NBR_FCLTY)=868838 Or (CCL_FACILITY.NBR_FCLTY)=505838 Or (CCL_FACILITY.NBR_FCLTY)=559653 Or (CCL_FACILITY.NBR_FCLTY)=540624 Or (CCL_FACILITY.NBR_FCLTY)=875179 Or (CCL_FACILITY.NBR_FCLTY)=545156 Or (CCL_FACILITY.NBR_FCLTY)=548913 Or (CCL_FACILITY.NBR_FCLTY)=813895 Or (CCL_FACILITY.NBR_FCLTY)=553482 Or (CCL_FACILITY.NBR_FCLTY)=552186 Or (CCL_FACILITY.NBR_FCLTY)=547770 Or (CCL_FACILITY.NBR_FCLTY)=554517 Or (CCL_FACILITY.NBR_FCLTY)=550565 Or (CCL_FACILITY.NBR_FCLTY)=525720 Or (CCL_FACILITY.NBR_FCLTY)=547557 Or (CCL_FACILITY.NBR_FCLTY)=815756 Or (CCL_FACILITY.NBR_FCLTY)=811682 Or (CCL_FACILITY.NBR_FCLTY)=551505 Or (CCL_FACILITY.NBR_FCLTY)=819473 Or (CCL_FACILITY.NBR_FCLTY)=838151 Or (CCL_FACILITY.NBR_FCLTY)=557335 Or (CCL_FACILITY.NBR_FCLTY)=554964 Or (CCL_FACILITY.NBR_FCLTY)=866218 Or (CCL_FACILITY.NBR_FCLTY)=834332 Or (CCL_FACILITY.NBR_FCLTY)=869778) AND ((CCL_FACILITY.CD_PRGRM_TYPE)="DC" Or (CCL_FACILITY.CD_PRGRM_TYPE) Is Null) AND ((CCL_CODE_TABLE_ROW.ID_CODE_TABLE)=72) AND ((CCL_CODE_TABLE_ROW_1.ID_CODE_TABLE)=45) AND ((CCL_FACILITY_ADDRESS.CD_ADDR_TYPE)="L"))
  4. ORDER BY CCL_EMPLOYEE.NBR_REGION, ([CCL_EMPLOYEE.NM_LAST] & ", " & [CCL_EMPLOYEE.NM_FIRST]);
  5.  
Thanks for all your help.
Nov 30 '07 #3
Rabbit
12,516 Expert Mod 8TB
Please use code tags. Well, now I know where you're trying to get the Max. So you're going to have to use an aggregate query. View > Totals. That will give you the option of setting up an aggregate query.
Nov 30 '07 #4

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

Similar topics

4
by: Charles A. Lackman | last post by:
Hello I have created a Dataview and have sorted it on the Date and ShiftNumber columns this works great, but when I want to use the Find Method it gives me the following error: Expecting 2...
40
by: Matt | last post by:
I want to know what is the latest C standard version? Is it C99? There are many terms I have heard, including C98, C99, C9X. Or should we call ANSI/ISO C? Please advise. Thanks!!
2
by: Extremest | last post by:
Here is the code I have so far. It connects to a db and grabs headers. It then sorts them into groups and then puts all the complete ones into another table. Problem I am having is that for some...
3
by: pjewett | last post by:
Hi All, New to the forum and to SQL. I'm running a query to pull sales records for a specific customer that returns several dates (for each transaction). I only need the most recent date from...
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: 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
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...
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
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,...
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...
0
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...
0
agi2029
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,...
0
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...

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.