Re: SELECT syntax
From: John Austin (anonymous_at_discussions.microsoft.com)
Date: 03/31/04
- Next message: _at_Ariel: "Re: What locking hints must I use to ensure the max(id) is not modified?"
- Previous message: Kevin Lisboa: "Decimal values..."
- Maybe in reply to: John Austin: "Re: SELECT syntax"
- Next in thread: Baisong Wei[MSFT]: "Re: SELECT syntax"
- Reply: Baisong Wei[MSFT]: "Re: SELECT syntax"
- Reply: Baisong Wei[MSFT]: "Re: SELECT syntax"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 31 Mar 2004 06:56:13 -0800
The following syntax looks better:
Dim cn As New ADODB.Connection, rs As New ADODB.Recordset, S$, rsJH As ADODB.Recordset
S = "Data Provider=SQLOLEDB;server=apsserver;database=jatest;trusted_connection=yes"
cn.Provider = "MSDataShape"
cn.Open S
S = "SHAPE { SELECT ID, [Name] FROM Personnel } " _
& " APPEND ( {SELECT EmpID, job_date FROM Job_History WHERE job_date >= COALESCE( " _
& " (SELECT MAX(job_date) FROM job_History WHERE job_date <= '2004-01-01' ),'1900-01-01') } " _
& " AS rsJH RELATE ID TO EmpID )"
With rs
.Open S, cn
Do While .EOF = False
Debug.Print "Emp="; !ID; !Name
Set rsJH = .Fields("rsJH").Value
With rsJH
Do While .EOF = False
Debug.Print " "; !EmpID; !Job_Date
.MoveNext
Loop
End With
Set rsJH = Nothing
.MoveNext
Loop
.Close
End With
cn.Close
But still is not finding "the highest Job_History record before a given date" on a person by person basis.
- Next message: _at_Ariel: "Re: What locking hints must I use to ensure the max(id) is not modified?"
- Previous message: Kevin Lisboa: "Decimal values..."
- Maybe in reply to: John Austin: "Re: SELECT syntax"
- Next in thread: Baisong Wei[MSFT]: "Re: SELECT syntax"
- Reply: Baisong Wei[MSFT]: "Re: SELECT syntax"
- Reply: Baisong Wei[MSFT]: "Re: SELECT syntax"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|