-1
我有多个学校,有多个年级和各种状态。 如果状态为-1或0,我需要获得每所学校每个年级的计数。 这些都来自同一张表。 '学生' 如果等级等于0,学校等于1234 ,如果等级等于1,学校等于1234 ,如果等级等于2,学校等于1234等于1234 接下来的一行将是一个不同的学校等各行不同的学校,每列从0级水平的12SQL - 一个表 - 多个列的计数
我试图
select Sched_NextYearGrade,
sum(case when Sched_NextYearGrade = ‘1’ then 1 else 0 end) as 'firstcount'
sum(case when Sched_NextYearGrade = '2' then 1 else 0 end) as 'secondCount'
from Students
Where (ENROLL_STATUS BETWEEN -1 AND 0)
group by Sched_NextYearGrade
我得到
ORA-00911: invalid character
00911. 00000 - "invalid character"
*Cause: identifiers may not start with any ASCII character other than
letters and numbers. $#_ are also allowed after the first
character. Identifiers enclosed by doublequotes may contain
any character other than a doublequote. Alternative quotes
(q'#...#') cannot use spaces, tabs, or carriage returns as
delimiters. For all other contexts, consult the SQL Language
任何人都可以帮忙吗?在此先感谢
您在第一个“sum”中的“1”处有微软引号。而你的列别名是不正确的。如果你确实需要一个区分大小写的别名,你可以使用双引号'作为“firstCount”。但通常你想避免像瘟疫一样。通常情况下,使用普通的不区分大小写的标识符并不像'firstCount'那样使用双引号。 –