David_Skov
Active Member
- Joined
- Jun 29, 2004
- Messages
- 267
I have a table with 100k+ rows. In one coloumn I have an indication of the period of the year (i.e. 200309 = sept. 2003) each period are represented several times.
I need to retrieve the quarters of each year. So for that I use the coloumn with periods in a query. I then sum by totals and through a calculation I get the quarters. Here is the SQL view:
INSERT INTO Kvartal ( Periode, Kvartal )
SELECT Data.Periode, IIf(Right([Periode],2)<4,1,IIf(Right([Periode],2)>3 And Right([Periode],2)<7,2,IIf(Right([Periode],2)>6 And Right([Periode],2)<10,3,4))) AS Kvartal
FROM Data
GROUP BY Data.Periode, IIf(Right([Periode],2)<4,1,IIf(Right([Periode],2)>3 And Right([Periode],2)<7,2,IIf(Right([Periode],2)>6 And Right([Periode],2)<10,3,4)))
HAVING (((IIf(Right([Periode],2)<4,1,IIf(Right([Periode],2)>3 And Right([Periode],2)<7,2,IIf(Right([Periode],2)>6 And Right([Periode],2)<10,3,4))))<=[Choose quarter (ie 3):]));
Problem is that it's so **** slow since it has to retrieve all that data, create totals and then do the calculations. So it's not a wonder it's slow.
But is there an easier way to do this? I hope there is
In advance tx
I need to retrieve the quarters of each year. So for that I use the coloumn with periods in a query. I then sum by totals and through a calculation I get the quarters. Here is the SQL view:
INSERT INTO Kvartal ( Periode, Kvartal )
SELECT Data.Periode, IIf(Right([Periode],2)<4,1,IIf(Right([Periode],2)>3 And Right([Periode],2)<7,2,IIf(Right([Periode],2)>6 And Right([Periode],2)<10,3,4))) AS Kvartal
FROM Data
GROUP BY Data.Periode, IIf(Right([Periode],2)<4,1,IIf(Right([Periode],2)>3 And Right([Periode],2)<7,2,IIf(Right([Periode],2)>6 And Right([Periode],2)<10,3,4)))
HAVING (((IIf(Right([Periode],2)<4,1,IIf(Right([Periode],2)>3 And Right([Periode],2)<7,2,IIf(Right([Periode],2)>6 And Right([Periode],2)<10,3,4))))<=[Choose quarter (ie 3):]));
Problem is that it's so **** slow since it has to retrieve all that data, create totals and then do the calculations. So it's not a wonder it's slow.
But is there an easier way to do this? I hope there is

In advance tx
