Varför går det inte att göra denna beräkning? Om [Users].[WorkTime] är null kommer resultatet för de posterna bli null. Kan vara det som strular. Jag hittade felet. Jag var tvungen att lägga med [Users].[WorkTime] i GROUP BY uttrycket. Då funkade det.SQL fråga
När jag byter ut [Users].[WorkTime] mot 552 så funkar det!
<code>
PARAMETERS UserN Text ( 255 ), FromDate DateTime, ToDate DateTime;
SELECT Min([TimeEntryLog].[InTime]) AS InTime, Max([TimeEntryLog].[OutTime]) AS OutTime, Int(Sum([TimeEntryLog].[OutTime]-[TimeEntryLog].[InTime])*1440)-60 AS SumWorkedTime, Int(Sum([TimeEntryLog].[OutTime]-[TimeEntryLog].[InTime])*1440)-[Users].[WorkTime] AS Flex, [TimeEntryLog].[Manually] AS Manuellt
FROM Users LEFT JOIN TimeEntryLog ON [Users].[UserID]=[TimeEntryLog].[UserID]
WHERE [Users].[UserName]=[UserN] AND ([TimeEntryLog].[InTime] BETWEEN FromDate AND ToDate)
GROUP BY [Users].[UserName], [Users].[FirstName], [Users].[LastName], Int([TimeEntryLog].[InTime]), [TimeEntryLog].[Manually];
</code>
<code>
PARAMETERS UserN Text ( 255 ), FromDate DateTime, ToDate DateTime;
SELECT Min([TimeEntryLog].[InTime]) AS InTime, Max([TimeEntryLog].[OutTime]) AS OutTime, Int(Sum([TimeEntryLog].[OutTime]-[TimeEntryLog].[InTime])*1440)-60 AS SumWorkedTime, Int(Sum([TimeEntryLog].[OutTime]-[TimeEntryLog].[InTime])*1440)-552 AS Flex, [TimeEntryLog].[Manually] AS Manuellt
FROM Users LEFT JOIN TimeEntryLog ON [Users].[UserID]=[TimeEntryLog].[UserID]
WHERE [Users].[UserName]=[UserN] AND ([TimeEntryLog].[InTime] BETWEEN FromDate AND ToDate)
GROUP BY [Users].[UserName], [Users].[FirstName], [Users].[LastName], Int([TimeEntryLog].[InTime]), [TimeEntryLog].[Manually];
</code>Sv: SQL fråga
Sv: SQL fråga