select case when
(homeid = <ID> and homegoals >= awaygoals)
or
(awayid = <ID> and awaygoals >= homegoals) then 1 else 0
end as point
, (select count(*)
from matcher
where <date column> < m.<date column>
and ((homeid = <ID> and homegoals < awaygoals)
or
(awayid = <ID> and awaygoals < homegoals))) as rg
, count(*) as streak
from matcher m
where (homeid = <ID> and homegoals >= awaygoals)
or (awayid = <ID> and awaygoals >= homegoals)
group
by point
, rg
order
by streak desc
limit 1
select top 1 case when
(homeid = <ID> and homegoals >= awaygoals)
or
(awayid = <ID> and awaygoals >= homegoals) then 1 else 0
end as point
, (select count(*)
from matcher
where matchdate < m.matchdate
and ((homeid = <ID> and homegoals < awaygoals)
or
(awayid = <ID> and awaygoals < homegoals))) as rg
, count(*) as streak
from matcher m
where (homeid = <ID> and homegoals >= awaygoals)
or (awayid = <ID> and awaygoals >= homegoals)
group
by point
, rg
order
by streak desc
Läs gärna @nders guide till vad som bör inkluderas då frågor ställs.
select top 1
iif((homeid = <ID> and homegoals >= awaygoals)
or
(awayid = <ID> and awaygoals >= homegoals),1,0) as point
, (select count(*)
from matcher
where matchdate < m.matchdate
and ((homeid = <ID> and homegoals < awaygoals)
or
(awayid = <ID> and awaygoals < homegoals))) as rg
, count(*) as streak
from matcher m
where (homeid = <ID> and homegoals >= awaygoals)
or (awayid = <ID> and awaygoals >= homegoals)
group
by point
, rg
order
by streak desc
SQL = "select top 1 " & _
" iif((homeid = " & ID & " and homegoals >= awaygoals) " & _
" or " & _
" (awayid = " & ID & " and awaygoals >= homegoals),1,0) as point " & _
" , (select count(*) " & _
" from matcher " & _
" where matchdate < m.matchdate " & _
" and ((homeid = " & ID & " and homegoals < awaygoals) " & _
" or " & _
" (awayid = " & ID & " and awaygoals < homegoals))) as rg " & _
" , count(*) as streak " & _
" from matcher m " & _
" where (homeid = " & ID & " and homegoals >= awaygoals) " & _
" or (awayid = " & ID & " and awaygoals >= homegoals) " & _
"group " & _
" by point " & _
" , rg " & _
"order " & _
" by streak desc"
Gav...
Error Type:
Microsoft JET Database Engine (0x80040E21)
You tried to execute a query that does not include the specified expression 'IIf(homeid=334 And homegoals>=awaygoals Or awayid=334 And awaygoals>=homegoals,1,0)' as part of an aggregate function.
252 ms totalt · 4 externa anrop · v20260731065814-full.14655e19