简体   繁体   中英

MS Access: Average with many condition

Ms Access 2020

I need to add an Average_Quantity column

Average_Quantity = Average of (Quantity of employees who have ticked 'x' on the Average(Y/N) column at every Day and every shift)

Here is the

桌子

with the Average_Quantity column

I am trying to use SQL function: AVG OVER PARTITION BY but it seems not working in SQL access

Someone could suggest any solution for this?

In MS Access, you cannot use a window function -- which is the simplest method. An alternative is a correlated subquery:

select t.*,
       (select avg(t2.quantity)
        from t as t2
        where t2.day = t.day and t2.shift = t.shift and 
              t2.[Average(Y/N)] = t.[Average(Y/N)]
       ) as group_average
from t;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM