Home > database >  Near the SQL 'SELECT' grammatical errors
Near the SQL 'SELECT' grammatical errors

Time:11-21

# 1 the CREATE VIEW V_AVG
# 2 AS
# 3 SELECT SelectCourse_StudentNo, AVG=AVG (SelectCourse_Score)
# 4 FROM SelectCourse
# 5 GROUP BY (SelectCourse_StudentNo)
# 6 SELECT *
# 7 the FROM V_AVG
# 8 WHERE AVG> 80

# 6 SELECT near a grammar mistakes,

CodePudding user response:

View can contain only one query statements, you this is clearly the two results,
Don't feel you should so check?
 CREATE VIEW V_AVG 
AS
WITH V_AVG
AS (SELECT SelectCourse_StudentNo,
AVG=AVG (SelectCourse_Score)
The FROM SelectCourse
GROUP BY (SelectCourse_StudentNo)
)
SELECT *
The FROM V_AVG
WHERE AVG & gt; 80;

CodePudding user response:

I felt directly from a having clause went, don't need to views,
 SELECT SelectCourse_StudentNo, AVG=AVG (SelectCourse_Score) 
The FROM SelectCourse
GROUP BY (SelectCourse_StudentNo)
HAVING AVG> 80

CodePudding user response:

# 1 the CREATE VIEW V_AVG
# 2 AS
# 3 SELECT SelectCourse_StudentNo, AVG=AVG (SelectCourse_Score)
# 4 FROM SelectCourse
# 5 GROUP BY (SelectCourse_StudentNo)

GO - this line and a line GO

# 6 SELECT *
# 7 the FROM V_AVG
# 8 WHERE AVG> 80

CodePudding user response:

Yes, yes yes, but I don't understand WITH V_AVG
AS (,,) this format

CodePudding user response:

The
reference 4 floor qq_46330184 reply:
yeah yeah yeah, but I don't understand WITH V_AVG
AS this format (,,)


Formal term is common table expressions common table express (CTE).
The biggest use is recursive query,
You, like:

Select * from (select * from XXX) as V_AVG

This kind of writing,

CodePudding user response:

Ok thank you
  • Related