the trick normaly with quarters:
That should calculate it properly in "one fell swoop" instead of the OR statements you have
Just FYI, if you are posting SQL on any/the forum... keep it readable. Yes using the code tags is a big part of it but also the presentation in particular with the long where clause.... you will agree this is much more presentable:
Offcourse Access messes it back up for you, sadly, but you will find people much more responsive I think.
Code:
Periode between left(per,4) * 100 + Int((right(per,2) -1) / 3) * 3
and left(per,4) * 100 + Int((right(per,2) -1) / 3) + 1 * 3
Just FYI, if you are posting SQL on any/the forum... keep it readable. Yes using the code tags is a big part of it but also the presentation in particular with the long where clause.... you will agree this is much more presentable:
Code:
SELECT Data.ClientID, Data.SorgID, Data.DivID, Data.BrandID, Data.DistChanID, Data.SourceID, Sum(Data.Qty) AS SumOfQty, Sum(Data.Val) AS SumOfVal
FROM Data
WHERE (((Right([per],2))>9 And (Right([per],2))<13) AND ((Data.Periode)>Left([per],4)*100+9 And (Data.Periode)<Left([per],4)*100+13))
OR (((Right([per],2))>6 And (Right([per],2))<10) AND ((Data.Periode)>Left([per],4)*100+6 And (Data.Periode)<Left([per],4)*100+10))
OR (((Right([per],2))>3 And (Right([per],2))< 7) AND ((Data.Periode)>Left([per],4)*100+3 And (Data.Periode)<Left([per],4)*100+ 7))
OR (((Right([per],2))>0 And (Right([per],2))< 4) AND ((Data.Periode)>Left([per],4)*100 And (Data.Periode)<Left([per],4)*100+ 4))
GROUP BY Data.ClientID, Data.SorgID, Data.DivID, Data.BrandID, Data.DistChanID, Data.SourceID;