Oracle不支持with子句吗

AlexChenLei 2004-11-16 09:49:56
with max_number as (select max(orderedNumber) as numbers from mcd_orderItems)
select mcd_foodList.foodName from mcd_foodlist, mcd_orderItems
where mcd_orderItems.orderedNumber = max_number.numbers and mcd_orderItems.FOODNO=mcd_foodlist.foodNo;

确报错:
unknown command beginning "with max_n..." - rest of line ignored
...全文
269 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
Chinatosun 2004-11-17
  • 打赏
  • 举报
回复
学习
ORARichard 2004-11-17
  • 打赏
  • 举报
回复
学习ing
hzf005 2004-11-17
  • 打赏
  • 举报
回复
WITH MAX_NUMBER AS (SELECT MAX(A.orderedNumber) as numbers ,B.foodName
FROM mcd_orderItems A,mdc_foodlist B
WHERE B.foodNo = A.FOODNO)
SELECT *
FROM MAX_NUMBER;
hzf005 2004-11-17
  • 打赏
  • 举报
回复
我們可以使用 WITH Clause 來定義一個 query block,然後在 SELECT statement 的其它地方來使用這個 query block。如果在一個很複雜的 Query 裡,我們必須重複的使用某個 subquery,使用 WITH Clause 可以降低 Query 的複雜度以及提高 performance。WITH Clause 所讀出的資料會暫存在 User 的 temporary tablespace 中。
SQL> WITH
2 DEPT_COSTS AS ( SELECT D.department_name, SUM(E.salary) AS dept_total
3 FROM EMPLOYEES E, DEPARTMENTS D
4 WHERE E.department_id = D.department_id
5 GROUP BY D.department_name),
6 AVG_COST AS ( SELECT SUM(dept_total)/COUNT(*) AS dept_avg
7 FROM DEPT_COSTS)
8 SELECT *
9 FROM DEPT_COSTS
10 WHERE dept_total > (SELECT dept_avg FROM AVG_COST)
11 ORDER BY department_name;

DEPARTMENT_NAME DEPT_TOTAL
------------------------------ ----------
Sales-- 304500
Shipping-- 156400
skystar99047 2004-11-17
  • 打赏
  • 举报
回复
没有
qiaozhiwei 2004-11-16
  • 打赏
  • 举报
回复
没有with语句
ATGC 2004-11-16
  • 打赏
  • 举报
回复
"with max_number "
这是什么数据库的SQL语句
oracle没有这样的写法
也不知道这是啥意思。。。。。

17,377

社区成员

发帖
与我相关
我的任务
社区描述
Oracle 基础和管理
社区管理员
  • 基础和管理社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧