为什么会出现此错误:
1054-“字段列表”中的未知列“ t.type”
我的表中有一列称为类型的列。我使用别名t获得了表“ tester”。
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,有什么想法吗?
谢谢。
-拉克西米
最佳答案
/ me点我的额头-对不起,对不起。
用这个:
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