SQLite3: SQLite不支持嵌套子查询吗?

SQLite3: SQLite不支持嵌套子查询吗? (环境:WIN7+ SQLite3 引擎版本: 3.7.16.1 )

SELECT CUST_NO, CUST_NAME, SUM(AMOUNT) As amount FROM (
select CUST_NO, CUST_NAME, SUM(AMOUNT) AS AMOUNT,order_date from  TB_ORDER
group by cust_no,cust_name,order_date
) AA
group by cust_no,cust_name,order_date

 

在提示窗口提示信息: 

执行查询出错: no such column: .CUST_NO 

 

 

解决方式: 表别名必须明确,并每个字段都要带上表别名, 例如:

SELECT AA.cust_no,AA.cust_name,AA.order_date, SUM(AA.AMOUNT) As amount FROM (
select CUST_NO, CUST_NAME, SUM(AMOUNT) AS AMOUNT,order_date from benluntongjiline
group by cust_no,cust_name,order_date
) AA
group by AA.cust_no,AA.cust_name,AA.order_date

 

 

posted @ 2022-05-31 18:14  samrv  阅读(252)  评论(0编辑  收藏  举报