0

I know we cannot use alias in select clause with group by.
Reference posts:
Group by alias (Oracle)
SQL - using alias in Group By

Even my practical example prove it.

But I don't understand why it is mentioned in "ORACLE DOCUMENTS" that we can use alias with GROUP BY,HAVING
https://docs.oracle.com/cd/E17952_01/refman-5.0-en/problems-with-alias.html

Community
  • 1
  • 1
  • 2
    The last link is **not** the manual for the Oracle database. It's the manual for MySQL - a completely different thing. The correct manual is here: https://docs.oracle.com/database/121/SQLRF/statements_10002.htm#i2182483 –  Jan 26 '16 at 10:21
  • @a_horse_with_no_name how do you say its MySql manual –  Jan 26 '16 at 10:25
  • Klick on the "Home" link at the bottom of that page. You can also easily tell because the examples on _that_ page are invalid SQL `id AS 'a'` - an identifier must be enclosed in double quotes, not single quotes in SQL (and in Oracle) –  Jan 26 '16 at 10:26
  • ya. Why oracle has two SQL's the MySQL,Oracle SQL.(am assuming MySQL is also an Oracle Product ) –  Jan 26 '16 at 10:29
  • @RahulTej - from [Wikipedia](https://en.wikipedia.org/wiki/MySQL), Sun Microsystems acquired MySQL AB in 2008 and then Oracle acquired Sun Microsystems on 27 January 2010 - so they already had their own RDBMS, and inherited MySQL. – Alex Poole Jan 26 '16 at 11:29
  • @a_horse_with_no_name Alright. But I guess the order of execution in MySQL might be same(i guess)1) FROM clause 2)WHERE clause 3)GROUP BY clause 4)HAVING clause 5)SELECT clause 6)ORDER BY clause. Then how come group by can know the reference made at select statment –  Jan 26 '16 at 12:55
  • A quick google reveals: http://stackoverflow.com/questions/24127932/mysql-query-clause-execution-order – Boneist Jan 26 '16 at 15:14

0 Answers0