Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / July 2006

Tip: Looking for answers? Try searching our database.

help with sql query

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ifoundgoldbug@gmail.com - 17 Jul 2006 18:21 GMT
Greetings

I have a table arranged thusly

Reason      Status     Est Comp Date   PMDate     Tool#
                                                       7/14/06
WFT083
Maintence   done          7/16/06                           WFT083

what my sql statement MUST do is search by Tool # then find the most
recent PMDate  then find if there is a work order with finished
maintence with a complete date AFTER the PMdate. also the returning
record will be a seperate record from the one with the PM date.

thanks for your help.
John Spencer - 17 Jul 2006 18:36 GMT
Something like the following query ***might*** work for you.

SELECT *
FROM TABLE as T
WHERE PMDate =
(SELECT Max(PMDATE)
FROM TABLE as Temp
WHERE Temp.[Tool#] = T.[Tool#])
OR T.[Est Comp Date] =
  (SELECT Min([Est Comp Date])
   FROM Table as Temp2
   WHERE Status = "Done" AND
   Temp2.[Tool#] = T.[Tool#] AND
   Temp2.[Est Comp Date] >=
           (SELECT Max(PMDATE)
            FROM TABLE as Temp3
            WHERE Temp3.[Tool#] = Temp2.[Tool#]))

> Greetings
>
[quoted text clipped - 11 lines]
>
> thanks for your help.
ifoundgoldbug@gmail.com - 17 Jul 2006 19:31 GMT
Thank you very much for this hunk of code by my PUNY little brain is
getting knotted thinking about it this statement is significant'y
larger than any other that I have done. i am going to try to decipher
it and please point me in the rigth direction where i get off

all the records that I am uering are on table [Work Order]  i am also
changing fields from [est comp date] to just [date]

SELECT T.PMDate, T.[Est Comp Date], T.[Tool #], *
FROM [work order] AS T
WHERE (((T.PMDate)=(SELECT Max(PMDATE)

' Selects the record of tool X with the latest PM date

FROM [work order] as Temp
WHERE Temp.[Tool#] = T.[Tool#]))) OR (((T.[Date])=(SELECT Max([Date])

'filters to see of the work order date is after that of the PMdate for
tool x

   FROM [work order] as Temp2
   WHERE Status = "Done" AND
   Temp2.[Tool#] = T.[Tool#] AND
   Temp2.[Date] >=
           (SELECT Max(PMDATE)
            FROM [work order] as Temp3
            WHERE Temp3.[Tool#] = Temp2.[Tool#]))));
'further filters to checks if PM is finished.

Here is basically the logic that i am trying for with the sql statement

grab tool x

look at the mad PMDate for tool x

Look at all work orders for tool x whos status is "Done" and who's
reason is "Maintence"  and finally whos Date is greater than the
PMDate.

if that makes sense.

Sorry for being so new I have only done very basic sql statements.

thanks again

Gold Bug
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.