我现在在使用IBM Db2查询时遇到了问题。我有下面的代码:
test_score_distribution = %sql SELECT test_score as "Test Score", count(*) as "Frequency" from INTERNATIONAL_STUDENT_TEST_SCORES GROUP BY test_score;
test_score_distribution
但是在执行时,我遇到了这个错误:
(ibm程序错误)ibm_db_dbi::程序错误:SQL结果列数失败:[IBM][CLI驱动程序][DB2/LINUXX 8664] SQL 0104 N在“SELECT test_score“后面发现意外的标记“as”。预期的标记可能包括:“和”。SQLSTATE=42601\r SQLCODE=-104 [SQL:SELECT考试分数作为考试分数,count(*)作为INTERNATIONAL_STUDENT_TEST_SCORES GROUP BY考试分数中的频率;](有关此错误的背景信息,请访问:http://sqlalche.me/e/f405)
我该怎么修呢?
3条答案
按热度按时间avkwfej41#
这对我来说解决了
mnowg1ta2#
我遇到了同样的问题,请尝试以下步骤:
然后,要更改名称,可以使用以下命令:
根据我的经验,使用SQL魔法命令需要删除每个查询上的空格。
您可以随时使用.DataFrame()函数保存Table,从而更加自由地工作
hfwmuf9z3#
as:不占用空间“Test Score”将给予错误“Test_Score”将正常
考试分数分布= %sql SELECT考试分数作为“考试分数,”count(*)作为“频数”来自国际学生考试分数GROUP BY考试分数;
测试分数分布