Salwa Badreddine
Salwa Badreddine

Reputation: 125

Every derived table must have its own alias error in mysql when I do have an alias

I keep getting this error and I have an alias declared? Any help would be appreciated.

CREATE VIEW maxJokes AS 
SELECT MAX(num) FROM 
( SELECT J.postUserID, count(*) AS num 
  FROM JokeTable J WHERE J.date >= '2018-03-01' 
  GROUP BY J.postUserID
)

Upvotes: 1

Views: 37

Answers (1)

Fahmi
Fahmi

Reputation: 37473

you've to add a alias name in the subquery

CREATE VIEW maxJokes AS 

SELECT MAX(num) FROM 
( 
   SELECT J.postUserID, count(*) AS num 
   FROM JokeTable J WHERE J.date >= '2018-03-01'
   GROUP BY J.postUserID
)A

Upvotes: 2

Related Questions