-4

Possible Duplicate:
every derived table must have its own alias

SELECT * FROM (SELECT Customer , Count(Customer) AS Reservation FROM Reservation GROUP BY customer) WHERE Reservation>=8 ORDER BY 1;

And getting the following error

#1248 - Every derived table must have its own alias.

the same works with MS Access. Appreciate your help in advance, thanks!!!

Community
  • 1
  • 1
  • possible duplicate of [every derived table must have its own alias](http://stackoverflow.com/questions/1888779/every-derived-table-must-have-its-own-alias), [MYSQL ERROR 1248 (42000): Every derived table must have its own alias](http://stackoverflow.com/questions/3363918/mysql-error-1248-42000-every-derived-table-must-have-its-own-alias), [I am getting a #1248 - Every derived table must have its own alias. I am using a WAMP server](http://stackoverflow.com/questions/5467801/i-am-getting-a-1248-every-derived-table-must-have-its-own-alias-i-am-using-a) – Wesley Murch May 12 '12 at 04:50
  • 1
    Welcome to StackOverflow. Before posting a question here, please do at least a basic search first. The exact error message you posted results in [every derived table must have its own alias](http://stackoverflow.com/questions/1888779/every-derived-table-must-have-its-own-alias). Searching first reduces clutter caused by duplicate questions and helps keep SO a useful resource. You might want to review the [FAQ](http://stackoverflow.com/faq) before posting any additional questions here, so you'll be familiar with how this site works. Thanks. :) – Ken White May 12 '12 at 04:54
  • Thanks @WesleyMurch and KenWhite, it works as charm, sorry for the inconvenience caused.I will make sure to check before posting next time. Thank you all for the help!!! – user1390625 May 12 '12 at 05:44

2 Answers2

1

Exactly what the error says, give your derived table an alias, by adding AS foo just before the WHERE.

Niet the Dark Absol
  • 320,036
  • 81
  • 464
  • 592
-1
SELECT 
    * 
FROM 
    (SELECT 
         Customer , 
         Count(Customer) AS Reservation 
     FROM 
         Reservation 
     GROUP BY 
         customer) AS SOMETABLEALIAS 
WHERE 
    Reservation>=8 
ORDER BY 1;
Eugene
  • 2,965
  • 2
  • 34
  • 39