为什么我收到此错误:
我的表中有一个名为type的列。我使用别名来获得表'测试'。
SELECT y.*,
(SELECT COUNT(*)
FROM (SELECT *,
CASE t.type
WHEN 'Advanced' THEN t.type
ELSE 'Non-Advanced'
END AS group_type
FROM tester) x
WHERE x.group_type = y.group_type
AND (x.grade1 + x.grade2) >= (y.grade1 + y.grade2)) AS rank
FROM (SELECT t.name,
t.grade1,
t.grade2,
t.type,
CASE t.type
WHEN 'Advanced' THEN t.type
ELSE 'Non-Advanced'
END AS group_type
FROM tester t) y
OMGPonies,有什么想法吗?
谢谢。
-Laxmidi
答案 0 :(得分:3)
使用此:
SELECT y.*,
(SELECT COUNT(*)
FROM (SELECT *,
CASE type
WHEN 'Advanced' THEN type
ELSE 'Non-Advanced'
END AS group_type
FROM tester) x
WHERE x.group_type = y.group_type
AND (x.grade1 + x.grade2) >= (y.grade1 + y.grade2)) AS rank
FROM (SELECT t.name,
t.grade1,
t.grade2,
t.type,
CASE t.type
WHEN 'Advanced' THEN t.type
ELSE 'Non-Advanced'
END AS group_type
FROM tester t) y
答案 1 :(得分:1)
子查询出错 - 此处未定义别名t
(SELECT *,
CASE t.type
WHEN 'Advanced' THEN t.type
ELSE 'Non-Advanced'
END AS group_type
FROM tester)x ....