indy500fan
asked on
Getting results from a a qry.
Friends,
I have a qry that isn't quite working.
Here is my qry (thanks to a modification to a solution provided by angelIII -- thanks again!):
Select st.ResultItemID, st.SectionTime
from SectionTimes st
where SectionID=-1
and SectionTime > -1
and RunID=38
and sectiontime in (Select Sum(SectionTime) From SectionTimes i Where
i.ResultItemID = st.ResultItemID
and RunID=38
and SectionID=-1
and SectionTime > -1
)
Now, there are 24 ResutItemID s for RunID 38; however no results show up when I run this qry. What's wrong with the qry. If I run the qry below, I get a result:
Select Sum(SectionTime) From SectionTimes Where
ResultItemID = 17
and RunID=38
and SectionID=-1
and SectionTime > -1
If that's the case, shouldn't I be getting results in the big qry?
Thanks in advance!
Regards,
Eric
I have a qry that isn't quite working.
Here is my qry (thanks to a modification to a solution provided by angelIII -- thanks again!):
Select st.ResultItemID, st.SectionTime
from SectionTimes st
where SectionID=-1
and SectionTime > -1
and RunID=38
and sectiontime in (Select Sum(SectionTime) From SectionTimes i Where
i.ResultItemID = st.ResultItemID
and RunID=38
and SectionID=-1
and SectionTime > -1
)
Now, there are 24 ResutItemID s for RunID 38; however no results show up when I run this qry. What's wrong with the qry. If I run the qry below, I get a result:
Select Sum(SectionTime) From SectionTimes Where
ResultItemID = 17
and RunID=38
and SectionID=-1
and SectionTime > -1
If that's the case, shouldn't I be getting results in the big qry?
Thanks in advance!
Regards,
Eric
ASKER
??? Kinda confused. It looks like the earlier solution you gave me.
I guess I thought that's what I did in the example above (apply the Sum to the inner qry?
I guess I thought that's what I did in the example above (apply the Sum to the inner qry?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Except for one little change (and i.SectionID=t.Sectionid -> became and i.SectionID=st.Sectionid), that works awesome!
THanks!
THanks!
that looks like very bad idea? don't you think: apply the sum() in the inner query...
what about this:
Select st.ResultItemID, st.SectionTime
from SectionTimes st
where SectionID=-1
and SectionTime > -1
and RunID=38
and sectiontime in (Select top 4 i.SectionTime From SectionTimes i Where
i.ResultItemID = st.ResultItemID
and i.RunID=st.RunID
and i.SectionID=t.Sectionid
and i.SectionTime > -1
)