SQL查询总提示缺少右括号,但是括号都没有问题了,请大神帮忙,急~~~

WITH PERSONRANK AS
(
SELECT
REALSALERID,
RANK () OVER (
  ORDER BY
   RATE DESC
) PERSONRANK
FROM(
   A AS(
SELECT
  REALSALERID,
    REALSALERNAME,
  SUM (ASSIGNLOTGROSS) LOTGROSS
FROM
  F_SALES_VIEW
WHERE
  TO_CHAR(CREDATE,'YYYY-MM-DD') BETWEEN SUBSTR('2016-12-31',0,4)||'-01-01' AND '2016-12-31' AND REALSALERID in
(
SELECT WORKCODE
  FROM DIM_PERSON
  WHERE OADEPTID IN (
  SELECT OADEPTID
  FROM DIM_PERSON
  WHERE PERSONID='NB0046'
  ))
GROUP BY
  REALSALERID,
    REALSALERNAME
),
B AS (
SELECT
EMPLOYEEID,  
SUM (DEBIT) DEBITL
FROM
  F_FINANCE_COST
WHERE
  TO_CHAR(CREDATE,'YYYY-MM-DD') BETWEEN SUBSTR('2016-12-31',0,4)||'-01-01' AND '2016-12-31' AND EMPLOYEEID in
(
SELECT WORKCODE
  FROM DIM_PERSON
  WHERE OADEPTID IN (
  SELECT OADEPTID
  FROM DIM_PERSON
  WHERE PERSONID='NB0046'
  ))
GROUP BY
EMPLOYEEID
) SELECT REALSALERID,
         REALSALERNAME,
ROUND (CASE DEBITL WHEN 0 THEN 0 ELSE LOTGROSS / DEBITL END,2) RATE
FROM
A
LEFT JOIN B ON A .REALSALERID = B .EMPLOYEEID
)
)
SELECT PERSONRANK AS 名次
FROM PERSONRANK
WHERE REALSALERID='NB0046'

问题大概是出在FROM 后面,就是不知道怎么解决
FineReportaasd 发布于 2017-1-22 15:39
回答问题
悬赏:2 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共2回答
最佳回答
0
Poseidon发布于2017-1-22 15:42(编辑于 2023-9-6 09:34)
555
最佳回答
0
zsh331发布于2017-1-22 16:06(编辑于 2023-9-6 09:34)
555
  • 0关注人数
  • 2529浏览人数
  • 最后回答于:2017-1-22 16:06
    活动推荐 更多
    热门课程 更多
    返回顶部