I have the following query:
(我有以下查询:)
CREATE VIEW VIEW#1 AS
SELECT * FROM rota
go
--view#02 – apresentar os voos programados para cada rota.
CREATE VIEW VIEW#2 AS
SELECT TOP (select COUNT(*) FROM voo) IDrota, IDvoo
FROM voo
ORDER BY IDrota
GO
--view#03 – apresentar os técnicos de apoio para cada um dos voos programados.
CREATE VIEW VIEW#3 AS
SELECT TOP (select COUNT(*) FROM tecnicosVoo) V.IDvoo, TV.IDfuncionario, F.PrimeirosNomes, F.UltimosNomes, F.fun??oTecnico FROM voo V
JOIN tecnicosVoo TV ON V.IDvoo = TV.IDvoo
JOIN funcionario F ON TV.IDfuncionario = F.IDfuncionario
ORDER BY IDvoo
GO
--view#04 – apresentar os voos programados para cada rota e os respetivos avi?es associados.
CREATE VIEW VIEW#4 AS
SELECT TOP (SELECT COUNT(*) FROM voo) R.IDrota, V.IDvoo, A.refAviao, A.modelo AS 'Modelo do avi?o' FROM voo V
JOIN rota R ON V.IDrota = R.IDrota
JOIN aviao A ON V.refAviao = A.refAviao
ORDER BY R.IDrota
--view#05 - apresentar para um voo a rela??o de lugares disponiveis
go
CREATE VIEW VIEW#5 AS
SELECT TOP (SELECT COUNT(*) FROM voo) VO.IDvoo, A.NT_passageiros 'Capacidade do avi?o', (SELECT count(*) FROM VendaVoo where IDvoo = VO.IDvoo and ocupacao = 1) 'Ocupados',
(select round((100.0 - ((select CAST((SELECT count(*) FROM VendaVoo where IDvoo = VO.IDvoo and ocupacao = 1) AS FLOAT) / CAST(A.NT_passageiros AS FLOAT)) * 100)), 2)) 'Percentagem de lugares disponiveis'
FROM voo VO
JOIN aviao A ON VO.refAviao = A.refAviao
And it is giving me this error: "Msg 102, Level 15, State 1, Procedure VIEW#4, Line 640 Incorrect syntax near 'GO'. Msg 111, Level 15, State 1, Procedure VIEW#4, Line 640 'CREATE VIEW' must be the first statement in a query batch."
(它给了我这个错误:“消息102,级别15,状态1,过程VIEW#4,行640'GO'附近的语法不正确。消息111,级别15,状态1,过程VIEW#4,行640'创建“ VIEW”必须是查询批处理中的第一条语句。”)
So the query creates the view 1, 2 and 3 but doesnt create the other one's.
(因此,查询将创建视图1、2和3,但不会创建其他视图。)
Someone know why? (有人知道为什么吗?)
ask by miguel__frtt translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…