R
Richard Lindsay
Hi everyone, I'm trying to create a SQL passthrough query or SQL view and
this ones driving me mad!
SQL Server 2000 for back end
Access 97 for front end
I have a table called Invoice, in which are the following fields
InvoiceNumber (Primary Key)
BookRef (indexed identifier for a client)
InvoiceDate (date of the Invoice)
Example data
InvoiceNumber, BookRef, InvoiceDate
10, 1, 31/08/2007
11, 2, 31/08/2007
12, 3, 31/08/2007
13, 1, 31/09/2007
14, 2, 31/09/2007
15, 3, 31/09/2007
16, 1, 31/10/2007
17, 2, 31/10/2007
18, 3, 31/10/2007
What I want to do is create a passthough query or view that returns the
Distinct InvoiceNumber, Bookref and PREVIOUS InvoiceDate where the
InvoiceDate is specified.
Thus when I specify InvoiceDate="31/10/2007"
This should return the following data, note the InvoiceNumber is for the
specified InvoiceDate but the PreviousInvoiceDate is from, you guessed it,
the previous invoice record for that BookRef.
InvoiceNumber, BookRef, PreviousInvoiceDate
16, 1, 31/09/2007
17, 2, 31/09/2007
18, 3, 31/09/2007
If was to specify InvoiceDate="31/09/2007"
This should return the following data
InvoiceNumber, BookRef, PreviousInvoiceDate
13, 1, 31/08/2007
14, 2, 31/08/2007
15, 3, 31/08/2007
I just can't seem to work it out
Can anyone point me in the right direction
I know you can't pass data to a view, but a hard coded example will give me
a starting point that I can convert to a passthrough.
Hope someone can help
Thanks
this ones driving me mad!
SQL Server 2000 for back end
Access 97 for front end
I have a table called Invoice, in which are the following fields
InvoiceNumber (Primary Key)
BookRef (indexed identifier for a client)
InvoiceDate (date of the Invoice)
Example data
InvoiceNumber, BookRef, InvoiceDate
10, 1, 31/08/2007
11, 2, 31/08/2007
12, 3, 31/08/2007
13, 1, 31/09/2007
14, 2, 31/09/2007
15, 3, 31/09/2007
16, 1, 31/10/2007
17, 2, 31/10/2007
18, 3, 31/10/2007
What I want to do is create a passthough query or view that returns the
Distinct InvoiceNumber, Bookref and PREVIOUS InvoiceDate where the
InvoiceDate is specified.
Thus when I specify InvoiceDate="31/10/2007"
This should return the following data, note the InvoiceNumber is for the
specified InvoiceDate but the PreviousInvoiceDate is from, you guessed it,
the previous invoice record for that BookRef.
InvoiceNumber, BookRef, PreviousInvoiceDate
16, 1, 31/09/2007
17, 2, 31/09/2007
18, 3, 31/09/2007
If was to specify InvoiceDate="31/09/2007"
This should return the following data
InvoiceNumber, BookRef, PreviousInvoiceDate
13, 1, 31/08/2007
14, 2, 31/08/2007
15, 3, 31/08/2007
I just can't seem to work it out
Can anyone point me in the right direction
I know you can't pass data to a view, but a hard coded example will give me
a starting point that I can convert to a passthrough.
Hope someone can help
Thanks