Я использую следующие sql для расчета продолжительности в первом запросе.
CDate(TimeSerial(Val([EndTime])\100,Val([EndTime]) Mod 100,0)-TimeSerial(Val([StartTime])\100,Val([StartTime]) Mod 100,0))) AS Duration
И получаю следующее, что хорошо ![enter image description here](https://i.stack.imgur.com/1sSqK.png)
And now, I would like to further calculate the total time of different lessons within a week in another query. Something like sum(iif(lesson="math",duration,0))
But since it's time data type sql server doesn't let me use the sum function.
I tried the following sql.
sum(hour(duration) + minute(duration)) AS Total_time
Но это не то, что я ожидал, потому что я хотел бы сохранить исходный формат с некоторыми критериями.
Есть удобный способ сделать это? Спасибо.