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

前端 未结 7 2033
我在风中等你
我在风中等你 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:19

    Old Question I know, but it may help someone knowing than while you cant order by aliases, you can order by column index. For example, this will work without error :

    SELECT 
     firstColumn,
     IIF(secondColumn = '', thirdColumn, secondColumn) As yourAlias
    FROM
     yourTable
    ORDER BY
     2 ASC
    

    The results would then be ordered by the values found in the second column wich is the Alias "yourAlias".

提交回复
热议问题