数据库
首页 > 数据库> > SQLite3: SQLite不支持嵌套子查询吗?

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

 

 

标签:AA,SQLite,date,cust,嵌套,AMOUNT,SQLite3,order,CUST
来源: https://www.cnblogs.com/samrv/p/16331781.html