许多iif语句,这些结果的总和

时间:2015-01-30 02:14:31

标签: database ms-access sum expressionbuilder

Access 2010: 以下是条件:

multiply with 1.5 if:
      monday - friday (08:00 - 16:00) 
      monday - friday (16:00 - 00:00) 
      satuday - sunday(08:00 - 16:00) 

multiply by 2 if:
      monday - friday (00:00 - 08:00)
      saturday- sunday (16:00 - 00:00)

multiply by 3 if:
      saturday - sunday (00:00 - 08:00)

我在表达式构建器中做了一个有趣的长表达式(不要笑,它有效):)

=IIf(([day]="monday" Or [day]="tuesday" Or [day]="wednesday" Or [day]="thursday" Or [day]="friday") And ([time_from]>=TimeValue("08:00") And [time_from]<=TimeValue("23:59") And ([time_until]>=TimeValue("08:00") And [time_until]<=TimeValue("23:59")));([time_until]-[time_from])*1,5;IIf(([day]="saturday" Or [day]="sunday") And ([time_from]>=TimeValue("08:00") And [time_from]<=TimeValue("16:00") And ([time_until]>=TimeValue("08:00") And [time_until]<=TimeValue("16:00")));([time_until]-[time_from])*1,5;IIf(([day]="monday" Or [day]="tuesday" Or [day]="wednesday" Or [day]="thursday" Or [day]="friday") And ([time_from]<TimeValue("08:00") And [time_until]<TimeValue("08:00"));([time_until]-[time_from])*2;IIf(([day]="saturday" Or [day]="sunday") And ([time_from]>=TimeValue("16:00") And [time_until]>=TimeValue("16:00"));([time_until]-[time_from])*2;IIf(([day]="saturday" Or [day]="sunday") And ([time_from]<=TimeValue("08:00") And [time_until]<=TimeValue("8:00"));([time_until]-[time_from])*3;"false")))))

有很多ifs,它有效......但我如何从这一切中得到一笔钱? 我希望我能说Sum(name_of_the_calculated_field)但它不起作用......

你可以帮我解决这个问题吗?如何总结这些结果?或者你可能有另一个更好的主意......如果是的话,请记住我是初学者!

感谢

0 个答案:

没有答案