Cannot group using alias columns

This sql query could get result

POST /_sql?format=txt
{
  "query": "select dt,sum(pay_order_cnt_1d) from (select dt,pay_order_cnt_1d from sol_t_order_home)t1 group by dt"
}

but when executing this sql query

POST /_sql?format=txt
{
  "query": "select datetime, sum(pay_order_cnt_1d) from (select dt as datetime,pay_order_cnt_1d from sol_t_order_home)t1 group by datetime"
}

it went wrong with following errMsg

{
  "error" : {
    "root_cause" : [
      {
        "type" : "sql_illegal_argument_exception",
        "reason" : "Cannot GROUP BY t1.datetime{r}#2399"
      }
    ],
    "type" : "sql_illegal_argument_exception",
    "reason" : "Cannot GROUP BY t1.datetime{r}#2399"
  },
  "status" : 500
}

can anyone explain it plz!!!