用总和除以数次优化

时间:2018-11-06 14:39:04

标签: sql sqlite

我用列的相同计数将“ Times”除以数...有一种方法可以优化查询,例如:

SELECT 
  strftime('%W', [DatumEintrag]) Woche ,
  SUM([FOO]) / COUNT (DISTINCT [DatumEintrag]),
  SUM([BAR]) / COUNT (DISTINCT [DatumEintrag]),
  SUM([SOMETHING]) / COUNT (DISTINCT [DatumEintrag]),
  SUM([SOMETHINGELSE]) / COUNT (DISTINCT [DatumEintrag])
  Material.[ID],
  COUNT (DISTINCT [DatumEintrag]) as Tage,
FROM [MainData] JOIN [Material] ON [MainData].MID= [Material].ID
WHERE ([FILTER] = '0015') AND ([MID] IN (156500, 156504)) AND 
[VOODOO] = '' AND ...

Count(DISTINCT [DatumEintrag])

被处死几次?

0 个答案:

没有答案