When I try to create a view, I get the error:
Msg 156, Level 15, State 1, Procedure viewFangst2021, Line 9 [Batch Start Line 445]
Incorrect syntax near the keyword 'SELECT'
I do not understand what is wrong with the code. The same thing happens if I am going to create a procedure.
Could it have something to do with settings or such in SQL? for this happens regardless of whether I create a view
CREATE VIEW viewFangst2021
AS
SELECT
FISK.FiskeNr, FISK.Fiskeslag,
COUNT(*) AS Antall,
ROUND(AVG(Vekt), 1) AS [Gjennomsnittsvekt (kg)]
FROM
FANGST, FISK
WHERE
FANGST.FiskeNr = FISK.FiskeNr
AND YEAR (Dato) = 2021
GROUP BY
FISK.FiskeNr, FISK.Fiskeslag
SELECT *
FROM viewFangst2021