I have the following code consisting of two queries from the same table. I want to combine the results with a sub query. The first query is :
declare @cnt int = 1
while @cnt < 13
beginselect maand,min(Stasie1) as minStasie1, max(stasie1) as maksStasie1, avg(stasie1) as gemStasie1
from GekombineerAlleMaande
where maand = @cntgroup by maand
set @cnt = @cnt +1
end;
The second is :
select min(datum) from
GekombineerAlleMaande
where stasie1 is not null
Both these queries works, but I want to combine the results.
My sub query is in brackets after the where statement of the first query :
declare @cnt int = 1
while @cnt < 13
beginselect maand,min(Stasie1) as minStasie1, max(stasie1) as maksStasie1, avg(stasie1) as gemStasie1
from GekombineerAlleMaande
where maand = @cnt
(select min(datum) from
GekombineerAlleMaande
where stasie1 is not null)
group by maandset @cnt = @cnt +1
end;
When execute the above I get the error : Incorrect syntax near the keyword 'group'.
What am I missing?
Regards