Subject | Re: How to optimize this query |
---|---|
Author | Christian Kaufmann |
Post date | 2004-05-25T19:17:40Z |
> What if you add a compound index :speed is a bit better with the original query (18 seconds now).
> after that you could try this one :I receive an error with this query:
>
> SELECT
> (SELECT R2.T_RESULTID FROM T_RESULT R2
> WHERE R2.T_AGEGROUPID = AG.T_AGEGROUPID and
> R2.T_ATHLETEID = A.T_ATHLETEID and
> R2.SWIMTIME = MIN(R.SWIMTIME)),
> MIN(R.SWIMTIME),
> A.LASTNAME,
"Dynamic SQL Error SQL error code = -104 Invalid expression in the
select list (not contained in either an aggregate function or the
GROUP BY clause)"
I don't really understand the first column in the select statement.
This is probably the column, that causes the error, because it's not
in the group clause.
> I'm not familar with this sport, but doesn't the AGEGROUP belongNo. I look at the data in two different ways:
> more to the ATHLETE then the RESULT table?
- Meet results: Here I display only the results of one meet and these
results are grouped by events and agegroups.
- Rankings: Here the agegroup has no effect. If I use the age here, it
is calcuated between the ATHLETE.BIRTHDATE and the SESSION.STARTDATE.
That's why I was thinking of changing the schema and adding the
T_STYLEID and the T_MEETID directly in the table T_RESULT.
cu Christian