Cómo escribir unirse a consulta de selección en MS Access?
-
19-09-2019 - |
Pregunta
Decir que tengo estas tablas con nombres de campo por debajo.
DailyLeaveLedger
dldEmployeeID
dldLeaveDate
InvoiceHeader
invEmployeeID
invWeekEnding
InvNumberWeeksCovered
Así que quiero una consulta selecciona los días de vacaciones, donde cubre una factura que dejan es decir invWeekEnding 02 de octubre y InvNumberWeeksCovered = 1 entonces cualquier licencia en el rango de 26 septiembre a 2 octubre está bien. También hay que tener en Asignar campos de empleado.
En 2003 MS Access por favor?
Solución
Probar
SELECT InvoiceHeader.invEmployeeID,
InvoiceHeader.invWeekEnding,
DateAdd("d",-[InvNumberWeeksCovered]*7,[invWeekEnding]) AS StartDate,
DailyLeaveLedger.dldLeaveDate
FROM InvoiceHeader
INNER JOIN DailyLeaveLedger
ON InvoiceHeader.invEmployeeID = DailyLeaveLedger.dldEmployeeID
WHERE (((DailyLeaveLedger.dldLeaveDate)
Between [invWeekEnding]
And DateAdd("d",-[InvNumberWeeksCovered]*7,[invWeekEnding])));
Lo que hice fue add -7 * InvNumberWeeksCovered a la invdate, y luego comprobar si hay fechas entre éstos.
Espero que ayude.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow