下面是oracle SQL,我想在Teradata格式中對其進行更改。teradata中的QUALIFY ROW_NUMBER
SELECT branch_code,
branch_no,
c_no,
cd_type
FROM (
SELECT branch_code,
branch_no,
c_no,
cd_type,
* * RANK() OVER (
PARTITION BY c_no ORDER BY cd_type
) RANK * *
FROM (
SELECT branch_code,
branch_no,
c_no,
MIN(cd_type) cd_type
FROM EMPLOYEE
WHERE S_CODE = 'C'
AND (branch_no) NOT IN (
SELECT branch_code
FROM DEPARTMENT
WHERE branch_code = 'ABC'
)
)
)
WHERE RANK = 1
我已經使用QUALIFY作爲如下。
SELECT branch_code,
branch_no,
c_no,
cd_type
FROM (
SELECT branch_code,
branch_no,
c_no,
cd_type,
* * QUALIFY ROW_NUMBER() OVER (
PARTITION BY c_no ORDER BY cd_type
) * * RANK
FROM (
SELECT branch_code,
branch_no,
c_no,
MIN(cd_type) cd_type
FROM EMPLOYEE
WHERE S_CODE = 'C'
AND (branch_no) NOT IN (
SELECT branch_code
FROM DEPARTMENT
WHERE branch_code = 'ABC'
)
)
)
WHERE RANK = 1
但是,得到錯誤「預期之間的事情,與出線。
我們可以把select語句資格嗎?
由於它是有益的。 – navku