jendeacott
Programmer
Hi,
I have the following SP which I would like to return a total
of the JourneyDuration field for a each day in the search criteria.
I also then want to change the JourneyDuration value from seconds to hours. i.e divide by 60 twice.
Everything works fine until I try and perform the above calculation which still works but does not group by the day.
I'm sure its something small I'm missing but cant see it.
Any help would be great.
Web Design Wetherby
Personal Web Design Service
I have the following SP which I would like to return a total
of the JourneyDuration field for a each day in the search criteria.
I also then want to change the JourneyDuration value from seconds to hours. i.e divide by 60 twice.
Everything works fine until I try and perform the above calculation which still works but does not group by the day.
I'm sure its something small I'm missing but cant see it.
Any help would be great.
Code:
Select DISTINCT (DAY(JourneyStart)) as TheDay, Month(JourneyStart) as TheMonth, Year(JourneyStart) as TheYear,
(CONVERT(numeric(10,1),(SUM(CONVERT(numeric(10,1), JourneyDuration)) /60) /60)) as Hours, MachineID, DataLoadID
From EH_Journey
where MachineID = @MachineID
AND (JourneyStart >= @StartDate and JourneyStart <= @EndDate)
AND (JourneyEnd <= @EndDate and JourneyEnd >= @StartDate)
group By MachineID, Year(JourneyStart), Month(JourneyStart), DAY(JourneyStart), DataLoadID, JourneyStart
Order By MachineID, Year(JourneyStart), Month(JourneyStart), DAY(JourneyStart)
Web Design Wetherby
Personal Web Design Service