I am building a VB.NET Windows Application form, and as a newbie cannot figure out an issue.
I have two sql tables, which are not joined. I wish to update one (skedulering) from another (ontledings) where I have certain "WHERE" clauses as in the following code :
I have tried : Ontledings.analisadatum = MAX(Ontledings.analisedatum). Alas it returns the following error :
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference
Any ideas ?
Regards
I have two sql tables, which are not joined. I wish to update one (skedulering) from another (ontledings) where I have certain "WHERE" clauses as in the following code :
opdraginvoer.Connection = konneksie opdraginvoer.CommandText = "update dbo.Skedulering " & _ "SET skedulering.skedph = ontledings.ph, skedulering.skedsuiker = ontledings.suiker," & _ "skedulering.skedsuur = ontledings.suur,skedulering.skedanalisedatum = ontledings.analisedatum " & _ "FROM Ontledings " & _ "WHERE Ontledings.plaasno=skedulering.skedplaasno " & _ "AND Ontledings.blokno=skedulering.skedblokno " & _ "AND YEAR(Ontledings.analisedatum) = year(getdate())" opdraginvoer.ExecuteNonQuery()After the last "WHERE" condition ( i.e. YEAR(Ontledings.analisedatum) = year(getdate()), I wish to include another condition which specifies the maximum date in the column (ontledings.analisedatum).
I have tried : Ontledings.analisadatum = MAX(Ontledings.analisedatum). Alas it returns the following error :
An aggregate may not appear in the WHERE clause unless it is in a subquery contained in a HAVING clause or a select list, and the column being aggregated is an outer reference
Any ideas ?
Regards
Last edited by a moderator: