需求:
软件access;(测试MySQL也会报错)
单表查询,
需要嵌套子查询遇到了错误,
错误代码:子查询没有赋予别名,
-- 查询订单首次出现的账期(错误代码) SELECT code1, month1, crm_bill_order_info.server_start_date FROM ( SELECT crm_bill_order_info.order_code AS code1, Min( crm_bill_order_info.account_month ) AS month1 FROM crm_bill_order_info WHERE crm_bill_order_info.customer = "客户名称" GROUP BY crm_bill_order_info.order_code ) INNER JOIN crm_bill_order_info ON ( code1 = crm_bill_order_info.order_code ) AND ( month1 = crm_bill_order_info.account_month );
得到错误提示:
1248 - Every derived table must have its own alias
修改:需要在子查询后赋予 “as [name]:as order_first_date”
-- 查询订单首次出现的账期 SELECT order_first_date.code1, order_first_date.month1, crm_bill_order_info.server_start_date FROM ( SELECT crm_bill_order_info.order_code AS code1, Min( crm_bill_order_info.account_month ) AS month1 FROM crm_bill_order_info WHERE crm_bill_order_info.customer = "客户名称" GROUP BY crm_bill_order_info.order_code ) AS order_first_date INNER JOIN crm_bill_order_info ON ( order_first_date.code1 = crm_bill_order_info.order_code ) AND ( order_first_date.month1 = crm_bill_order_info.account_month );
当遇到错误才能记忆的更清晰,才能提高。
入门的never_late_to_learn
不积跬步,无以至千里.不积小流,无以成江海–加油