0

我如何制作第五列来划分我从 Vikt 和 AntalOrder 获得的值?

/*

*/
select O08T1.pickdate,
          O08T1.divcode,
sum(O08T1.calcwght) as Vikt,
sum(O08T1.calcvol) as Volym,
count(O08T1.ordno) as AntalOrder

from O08T1  
group by O08T1.pickdate, O08T1.divcode
order by Pickdate DESC
4

1 回答 1

1

虽然你可以使用显式除法,但我猜那ordno是 never NULL。如果是这样,您可以将查询表述为:

select O08T1.pickdate, O08T1.divcode,
       sum(O08T1.calcwght) as Vikt, sum(O08T1.calcvol) as Volym,
       count(*) as AntalOrder,
       avg(O08T1.calcwght) as avg_vikt
from O08T1  
group by O08T1.pickdate, O08T1.divcode
order by Pickdate DESC
于 2021-06-10T11:15:26.503 回答