MS-Access -> SELECT AS + ORDER BY = error

前端 未结 7 2031
我在风中等你
我在风中等你 2020-12-07 01:52

I\'m trying to make a query to retrieve the region which got the most sales for sweet products. \'grupo_produto\' is the product type, and \'regiao\' is the region. So I got

相关标签:
7条回答
  • 2020-12-07 02:34

    Why it doesn't consider the newly created 'column' I made in the select clause?

    Because Access (ACE/Jet) is not compliant with the SQL-92 Standard.

    Consider this example, which is valid SQL-92:

    SELECT a AS x, c - b AS y
      FROM MyTable
     ORDER
        BY x, y;
    

    In fact, x and y the only valid elements in the ORDER BY clause because all others are out of scope (ordinal numbers of columns in the SELECT clause are valid though their use id deprecated).

    However, Access chokes on the above syntax. The equivalent Access syntax is this:

    SELECT a AS x, c - b AS y
      FROM MyTable
     ORDER
        BY a, c - b;
    

    However, I understand from @Remou's comments that a subquery in the ORDER BY clause is invalid in Access.

    0 讨论(0)
提交回复
热议问题